我有实体的编辑表单。有元件
$feedback = new FeedbackViewer('Feedback');
$feedback->setLabel('Feedback')->setRequired(false);
$feedback->setPostId($this->testimonialId);
$feedback->setAppId($this->config->testimonials->appId);
$feedback->setIgnore(true);
$this->addElement($feedback);
这个反馈查看器加载带有另一个zf数据网格的iframe,该数据网格显示表单内部的反馈。我在ZF数据网格中使用此表单
$entityId = $this->getRequest()->getParam('edit');
if ($entityId) {
$entityForm = call_user_func($formCallback, $entityId);
$form->setUsePreDefinedFormElements(true);
$form->setForm($entityForm);
}
但ZF数据网格在保存操作后触发错误Validation failed。删除feedbacks元素可以使其正确保存。有什么建议吗?
$grid->setForm($form);
if($action != 'show') {
$form->getForm()->getElement('form_reset')->setLabel(null);
$form->getForm()->getElement('form_submit')->setLabel(null);
$gridParam = $this->getRequest()->getParam('grid');
$startParam = $this->getRequest()->getParam('start');
if ($gridParam) {
if ($gridParam == 'all') {
$gridParam = 'index';
}
// Attach to event listener custom redirect action
$grid->listenEvent('crud.after_update', array($this, 'setGridRedirectCallback'), array('action' => $gridParam, 'page' => $startParam));
$grid->listenEvent('crud.after_delete', array($this, 'setGridRedirectCallback'), array('action' => $gridParam));
$form->getForm()->getElement('form_reset')->setAttribs(array('onclick' => 'window.location.href = "/admin/' . $gridParam . (($startParam) ? '/start/' . $startParam : '') . '";'));
}
我把这个问题放在If标签中解决了,找不到更好的解决方案。