Thanks for the correction, but I am still getting the same error...

I am using version 1.2.1.8004

On Feb 26, 6:27 pm, "dr. Hannibal Lecter" <lecter...@gmail.com> wrote:
> Hmmm...which version of cake are you using?
>
> The error you're getting is because your model names should be
> singular, not plural. So instead:
>
> var $uses=array('Courses','Providers');
>
> try
>
> var $uses = array('Course', 'Provider');
>
> And see if that helps.
>
> On Feb 26, 11:00 pm, Jose <jfe...@gmail.com> wrote:
>
> > Hi All,
>
> > I have two controllers: courses and providers defined as:
> > class CoursesController extends AppController {
> >         var $name='Courses';
> >         var $uses=array('Courses','Providers');
> >         var $belongsTo = array('Provider' =>
> >                 array('className'    => 'Provider',
> >                         'conditions'   => '',
> >                         'order'        => '',
> >                         'foreignKey'   => 'provider_id'
> >                         ));
>
> > class ProvidersController extends AppController {
> >         var $name='Providers';
> >         var $hasMany=array('Course');
>
> > in the add function at the CoursesController I have:
> >         function add() {
> >                 if (!empty($this->data)) {
> >                         if ($this->Course->save($this->data)) {
> >                                 $this->flash('Your Course has been saved.', 
> > '/courses');
> >                         }
> >                 } else {
> >                         $this->set('providers', 
> > $this->Course->Provider->generateList());
>
> >             $this->render();
> >                 }
> >         }
>
> > and at the view for the add I have:
> > echo $form->create('Course');
> > echo $form->input('name');
> > echo $form->input('provider_id');
> > $html->selectTag('Course/provider_id', $providers, $html->tagValue
> > ('Course/provider_id'), array(), array(),false, true)));
> > echo $form->end('Save Post');
>
> > The problem then getting into the /add is:
>
> > Notice (8): Undefined property: CoursesController::$Course [APP
> > \controllers\courses_controller.php, line 32]
> > Notice (8): Trying to get property of non-object [APP\controllers
> > \courses_controller.php, line 32]
>
> > Fatal error: Call to a member function generateList() on a non-object
> > in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\app
> > \controllers\courses_controller.php on line 32
>
> > the line 32 is: $this->set('providers', $this->Course->Provider-
>
> > >generateList());
>
> > I have read several samples and it looks I am doing the right thing,
> > but something it's missing!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to