I am a newbie in cakephp. I need to get values from the DB and populate it in the view. From all the forums I have visited, I came to know that genera开发者_高级运维teList()
has been deprecated. If so, what do I need to use. where should I place the code. Could any of you explain to me the code part.
in you controller action for the view containing the list:
$associatedItems = $this->Item->AssociatedItem->find('list');
$this->set(compact('associatedItems'));
Change items and associated items for your actual model names.
The find('list') method returns an array of id => displayField pairs, e.g. for Posts with a title field, it will return an array like (1 => 'My first post') etc. See the cook book page for retrieving data from your models for more information.
The Cake Form helper, when you call
echo $form->input('associated_item_id');
will detect there is a variable available in the view called associatedItems and render a select tag with the contents of $associatedItems as the options.
精彩评论