ZF Datagrid编辑表单验证失败,原因是忽略了元素



我有实体的编辑表单。有元件

          $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标签中解决了,找不到更好的解决方案。

相关内容

  • 没有找到相关文章

最新更新