Tuesday, December 6, 2011

Re: Dropdown list is empty

automagic only works with the $variableName being the same than field
name (nothing to do with foreignKeys)

$recipients means that the field should be "recipient" or
recipient_id" or "recipients"
so in your case try $toUsers or simply set it manually using
'options'=>$recipients


On 6 Dez., 16:41, Daniel <danwgr...@gmail.com> wrote:
> I have an email add view with a dropdown list for a field called
> to_user_id (relating to the users table).  The problem is that the
> dropdown list is empty.  Here is code from the controller:
>
> $recipients = $this->Email->Recipient->find('list');
> $this->set(compact('recipients'));
>
> ...and in the add.ctp file:
>
> echo $this->Form->input('to_user_id');
>
> I don't know if this makes a difference but in the users model:
>
> var $displayField = 'username';
>
> In the email model:
>
> var $belongsTo = array(
>         'Recipient' => array(
>                 'className' => 'User',
>                 'foreignKey' => 'to_user_id',
>                 'conditions' => '',
>                 'fields' => '',
>                 'order' => ''
>         ),
> ...
>
> Any ideas as to why the dropdown list is empty?
>
> Thanks.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: