我action.class.php調用一個成員函數bind()的一個非對象在
if ($this->getRequest()->getMethod() == sfRequest::GET) {
$this->formShoppingList = new ShoppingListForm(array(
'shoppinglist' => $items,
), array('shoppinglist_id' => $list_id));
}
if ($request->isMethod('post')) {
$this->formShoppingList->bind($request->getParameter('shoppinglist'));
print_r($this->fromShoppingList;
}
我的lib/ShoppingListForm.php:
<?php
class ShoppingListForm extends BaseForm {
public function configure() {
$shoppinglist_id = $this->getOption('shoppinglist_id');
$this->setWidgets(array(
'shoppinglist' => new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35')),
'action_id' => new sfWidgetFormInputHidden(array()),
'list_id' => new sfWidgetFormInputHidden(array(),array('value' => $shoppinglist_id)),
));
$this->widgetSchema->setLabels(array(
'shoppinglist' => '',
));
$this->setValidators(array(
'shoppinglist' => new sfValidatorString(array('max_length' => 5000), array(
'required' => 'ShoppingList is empty.'
)),
'action_id' => new sfValidatorString(array('required' => false)),
'list_id' => new sfValidatorString(array('required' => false))
));
$this->widgetSchema->setNameFormat('shoppinglist[%s]');
gfFormHelper::addRequiredToLabel($this);
}
}
?>
當我提交表單,錯誤即將到來:
Fatal error: Call to a member function bind() on a non-object in....
Tampa-Data: shoppinglist%5Bshoppinglist%5D=liste+15%0D%0A shoppinglist%5Baction_id%5D=1 shoppinglist%5Blist_id%5D=15
爲什麼?解?