Hi, The form helper judges the options of a select field according to the section of field name before '_id'. For example, it uses $departments if field name is 'department_id', so try to set variable name as 'parents' instead of 'parentUsers'.
Hope this helps. Amit Badkas PHP Applications for E-Biz: http://www.sanisoft.com On Sun, Dec 26, 2010 at 4:34 AM, Valter <[email protected]> wrote: > All, > > I a newbie to cake and need your expert help. I've created a db schema > then baked it (used cake naming convention all the way). See below the > schema: > > users {id(PK), name, lastname, username, password, email, > department_id(FK), parent_id(FK)**} > > **parent_id refers to the users table recursively (a user can > supervise another user). When I bake it to create all the CRUD > functions It seems to work fine but then when I try to ADD a new user > the drop down menu do not populate itself with the data I entered > manually in the database. > > Funily enough, when I debug() the parentUsers table generated by cake, > it returns the values I was expecting in the dropdown element. > > See the bake generated code below: > > thanks > > ********** View************* > <?php > debug($parentUsers); > echo $this->Form->input('name'); > echo $this->Form->input('last_name'); > echo $this->Form->input('username'); > echo $this->Form->input('password'); > echo $this->Form->input('email'); > echo $this->Form->input('department_id'); > echo $this->Form->input('parent_id'); > ?> > **************************** > > ********** Controller ************* > . > $departments = $this->User->Department->find('list'); > $parentUsers = $this->User->ParentUser->find('list'); > $this->set(compact('departments', 'parentUsers')); > . > . > .**************************** > ********** Model ************* > var $belongsTo = array( > 'ParentUser' => array( > 'className' => 'User', > 'foreignKey' => 'parent_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > *************************** > > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<cake-php%[email protected]>For > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
