getStatusObject[$key]->... Not Round brackets... Dirk Hartmann Schenckstr. 10 57074 Siegen m
Am 23.07.2009 um 17:12 schrieb -gary- <gary.dun...@gmail.com>: > > Apologies for replying to my own post, but does anybody have any idea > on this one? I have no idea why I am getting this error. > > Thanks in advance. > > On Jul 22, 7:43 pm, -gary- <gary.dun...@gmail.com> wrote: >> Hi, >> >> I am trying to do a multiple edit on a database table. >> >> Whn I output like this: >> [code] >> <?php echo $form->getStatusObject($key)->getStatusname() ?> >> [/code] >> I get this error: >> [code] >> Fatal error: Call to a member function getStatusname() on a non- >> object >> [/code] >> >> When I comment the above out the rest of the fields print out with >> the >> data as expected but with this error at the bottom of the page: >> >> [code] >> Fatal error: Cannot use object of type sfFormField as array >> [/code] >> >> Can you see what I am doing wrong here? I put the full code below. >> >> Thank you in advance. >> >> Template: >> [code] >> <?php foreach($form as $key => $status): ?> >> <tr> >> <td><?php echo $form->getStatusObject($key)->getStatusname >> () ?></td> >> <td> >> <?php echo $status['statusOrder']; // should print text >> field with db value populated ?> >> <?php echo $status['statusOrder']->renderError(); ?> >> </td> >> <td> >> <?php echo $status['startend'] ?> >> <?php echo $status['statusOrder']->renderError(); ?> >> </td> >> </tr> >> <?php endforeach; ?> >> [/code] >> >> Forms: >> [code] >> <?php >> >> class StatusEditForm extends sfForm >> { >> protected $status_objects = array(); >> >> public function configure() >> { >> foreach( StatusPeer::doSelect(new Criteria()) as $status_object ) >> { >> $this->embedForm('status_'.$status_object->getId(), new >> StatusForm($status_object)); >> } >> } >> >> public function getStatusObject($key) >> { >> return (isset($this->status_objects[$key])) ? $this- >> >status_objects >> [$key] : null; >> } >> >> public function save() >> { >> $values = $this->getValues(); >> >> foreach($this->getEmbeddedForms() as $key => $status_form) >> { >> $status_form->updateObject($values[$key]); >> $status_form->getObject()->save(); >> } >> } >> >> } >> >> [/code] >> >> [code] >> class StatusForm extends BaseStatusForm >> { >> protected $status_objects; >> >> protected static $startend_choices = array( >> 'entry_point' => 'Entry Point', >> 'end_point' => 'End Point' >> ); >> >> public function configure() >> { >> // completely unset any fields you don't need >> unset( >> $this['id'], >> $this['report'] >> ); >> >> $this->widgetSchema['id'] = new sfWidgetFormInputHidden(); >> $this->widgetSchema['startend'] = new sfWidgetFormSelectRadio >> ( array( >> 'choices' => self::$startend_choices >> )); >> $this->widgetSchema['statusOrder'] = new sfWidgetFormInput(); >> >> $this->validatorSchema['startend'] = new sfValidatorChoice(array( >> 'choices' => array_keys(self::$startend_choices) >> )); >> } >> >> } >> [/code] >> >> This seems to be where the problem is. It's not returning an object: >> >> [code] >> public function getStatusObject($key) >> { >> return (isset($this->status_objects[$key])) ? $this- >> >status_objects >> [$key] : null; >> } >> [/code] >> >> Does anybody have any idea why? >> >> Thank you. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---