Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 708673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:25:02+00:00 2026-05-14T04:25:02+00:00

Hey! Total CakePHP noob here. Updated at bottom / This is sort of a

  • 0

Hey! Total CakePHP noob here.

Updated at bottom /

This is sort of a two fold question. In a view that is used for adding user objects I would like to use a drop down (selection) field in the form.

Each user belongs to a group so when I add a user I want a drop down that contains all of the groups that the user could possibly join. Currently the group_id field is a textfield. I know how to force it to be a selection field, but I don’t know how to populate the selection with the names of the groups programmatically.

The Current method:

echo $form->input('group_id', array(
    '1' => 'NameOfGroup1',
    '2' => 'NameOfGroup2',
    '3' => 'NameOfGroup3')
    );

I want to generate the options array programmatically though.

echo $form->input('group_id', $this->Group->find('list'));

This doesn’t work though. I get an error:

Undefined property: View::$Group [APP/views/users/add.ctp, line 8]

To me this means that I don’t have access to the Group object from inside my user view.

How can I accomplish this? Again, I want to do it programmatically so that it updates as I add groups or remove them.

EDIT: Why doesn’t this work?

// In views/users/someaction.ctp
echo $form->input('group_id',
                  array('options' => $this->formOptionsGroups)
                  );

// In controllers/users_controller.php
function someaction() {
    // Any other logic
    $this->set('formOptionsGroups', $this->Group->find('list'));
}

Error is that Group is an undefined object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:25:03+00:00Added an answer on May 14, 2026 at 4:25 am

    I think it’s not necessary to use the requestAction function in your situation.Because you can get the grouplist in your users controller easily then assign it to your user-add page where you need it.That would be more graceful.

    BTW,about requestAction from the cookbook: requestAction is best used in conjunction with (cached) elements – as a way to fetch data for an element before rendering.

    E.g

    /*code In the your user-add action of the users controller*/
    function useradd()
    {
        ......
        //your ownstuff skipped
    
        $grouplist = $this->User->Group->find('list');
        $this->set("grouplist",$grouplist);   
    }
    

    Then in your view of the useradd action :

    echo $form->input('group_id', $grouplist);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I'm a total noob when it comes to Objective-C / iPhone development.
Hey guys. This is a follow-on from this question : After getting the right
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey. How can I get a total number of rows in a file (do
hey i have a counter text here and i need to know how to
Hey guys. I have a method that gets called each second which I want
Hey, I have a tables called downloads, and in that table it stores the
Hey, I'm a fresh out of college graduate. I'm working on a project that
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.