I forgot to mention I am looking to get a dropdown in the add form... On Feb 26, 6:00 pm, Jose <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
