Thursday, March 15, 2012

Re: Filling in a drop down box - comments on code please

Muka, you are correct, it was just a copy/paste from some of my code and I changed somethings to Choice but forgot to change the $this->Article

On Wednesday, March 14, 2012 12:57:41 AM UTC-7, muka wrote:

Il 14/03/2012 08:07, andrewperk ha scritto:
> Whenever I want to access a tables data from another controller that
> doesn't have a relationship with the other table I use:
> class MyController extrends AppController {
>
>     public function action() {
>         App::uses('Choice', 'Model');
>         $this->Article = ClassRegistry::init('Choice');
>         $this->set('choices', $this->Choice->find('list'));
>     }
> }
>
Hi, I think this is not conceptually correct: why $this->Article should
became Choice model?

class MyController extrends AppController {
     public function action() {

         $this->loadModel("Choice");
         $this->set('choices', $this->Choice->find('list'));

     }

}

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate