0

我有实体的编辑表格。有元素

          $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 数据网格在保存操作后触发错误验证失败。删除反馈元素使其正确保存。有什么建议么?

4

1 回答 1

0
 $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 标记中解决了这个问题,但找不到更好的解决方案。

于 2012-08-23T14:33:54.133 回答