我有一个zf2问题,形式绑定对象程序,简而言之我试图通过表单验证通过表单对象自动化数据交换到我的实体,为此我实现了两个接口InputFilterAwareInterface和ArraySerializableInterface,早期的接口是表单对象获取输入过滤器,后面的接口用于表单和我的实体的数据交换.下面是我控制器中放置的代码的简短片段.
//Controller code
$companyForm = new \Manage\Forms\CompanyForm();
$companyEntity = $this->getServiceLocator()->get('Manage/CompanyEntity');
$postData = $this->getRequest()->getPost()->toArray();
$companyEntity->exchangeArray($postData);
$companyForm->bind($companyEntity);
if($companyForm->isValid(){
....
}
Run Code Online (Sandbox Code Playgroud)
这应该在我的实体对象中自动调用exchangeArray()方法并且它正确地执行但问题是数据是空的,并且数据数组包含具有inputfilter设置的键,所有其他数据键都丢失.
如果需要,我可以添加更多代码片段.
谢谢Raj