Issue
I have two table users and Areas.Areas has a relation with users.So I have add users_id in Areas table.After bake I get the output fine.But here in areas add form user field is showing users_id in select box.Here I want to show users_name.How can I change it?
Here is the model code
MadAreas' => array(
'className' => 'MadAreas',
'foreignKey' => 'users_id'
)
In controller
$madAreas = $this->MadArea->Users->find('list');
In add.ctp
echo $this->Form->input('users_id',array( 'label' => false, 'class'=>'form-control' ));
Solution
Try specifying the fields you want in your find statement:
$madAreas = $this->MadArea->Users->find('list', array(
'fields' => array('id','username')
)
);
Changing the $displayField in the model as mentioned in @mponos-george's answer should do it anyways, just make sure you clear your Cache files after changing the model value.
Answered By - Ayman Bedair Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.