我的 action.class.php
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;
}
我的库/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);
}
}
?>
当我提交表单时,出现错误:
致命错误:在...中的非对象上调用成员函数 bind()
坦帕数据:shoppinglist%5Bshoppinglist%5D=liste+15%0D%0A shoppinglist%5Baction_id%5D=1 shoppinglist%5Blist_id%5D=15
为什么?解决方案?