我在模型 TaiKhoan 中有这个方法
public function getInputFilter()
{
if (!$this->inputFilter)
{
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array(
'name' => 'TenTaiKhoan',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
)));
$inputFilter->add($factory->createInput(array(
'name' => 'MatKhau',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
)));
}
return $this->$inputFilter;
}
然后我在我的控制器中使用它
$taikhoan = new TaiKhoan();
$form->setInputFilter($taikhoan->getInputFilter());
当我运行时,它告诉我这个错误
Catchable fatal error: Object of class Zend\InputFilter\InputFilter could not be converted to string in C:\wamp\www\ZF\module\CPanel\src\CPanel\Model\TaiKhoan.php on line 59