I don't think that's correct. The compact function looks for local variables
and compacts them into variables that are sent to the view. So
$this->set(compact('musicList')); is sufficient so long as $musicList exists
when called. The idea of using compact is that you can send lots of variables
through in a single statement: $this->set(compact('one', 'two', 'three'));
would produce view variables $one, $two and $three (assuming they existed in
the controller function). You can use: $this->set('musicList', $musicList);
instead (i.e. with compact()) to send a single variable through. You'd need to
repeat it for each variable though.
On 20 Jun 2011, at 07:12, andy_the ultimate baker wrote:
> u should check the relation of album and music
>
> and while $this->set(compact('musicsList'));
> use this
> $this->set(compact('musicsList', $musicsList));
>
> and u will collect them in ur view
>
> Regards
>
> Anand
>
> On Jun 20, 11:07 am, madusanka hettiarachchi <[email protected]>
> wrote:
>> hi guys,
>>
>> Hi CRUSH, Did you get solve your problem? I have same as you! I did the
>> changes which Jeremy said, bt It gives error like this,
>>
>> Undefined property: Album::$Music
>> [*APP\controllers\albums_controller.php*, line *69*]
>> Code
>>
>> function index(){ //$lists =
>> $this->Album->Music->find('list',array('fields'=>array('id','name')));
>> $musicsList = $this->Album->Music->find('list');
>>
>> AlbumsController::index() - APP\controllers\albums_controller.php, line 69
>> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
>> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
>> [main] - APP\webroot\index.php, line 83
>>
>> *Fatal error*: Call to a member function find() on a non-object in *
>> D:\xampp\htdocs\...\app\controllers\albums_controller.php* on line *69
>> *
>> here are my codes
>>
>> ::::view:::
>> echo $form->input('music_track_id', array('label' => 'Music Track'));
>>
>> ::::controller:::::::
>>
>> $musicsList = $this->Album->Music->find('list'); //(line 69)
>> $this->set(compact('musicsList'));
>>
>> can any body help me?
>>
>> Ganganath Hettiarachchi
>
> --
> 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
> [email protected] For more options, visit this group at
> http://groups.google.com/group/cake-php
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php