Zend Framework 2中的一个表单中有许多相同的对象

时间:2013-12-21 22:03:03

标签: php zend-framework2

我正在尝试使用表单创建一个页面来编辑许多对象。 我有产品实体,product_details实体和product_details_list实体。 在details_list中,我列出了可能的产品属性 并且需要有所有product_details的表单。 product_details实体具有每个属性的detail_id(from),shortTxt和longTxt。我这样做了:

$this->details_list = $objectManager
          ->getRepository('Product\Entity\ProductDetailsList')
          ->findAll();
$form = new \ZfcAdmin\Form\ProductDetailsForm();

                    foreach($this->details_list as $detail) {
                            $form->add(array(
                                    'type' => 'Zend\Form\Element\Textarea',
                                    'name' => 'shortTxt_'.$detail->getId(),
                                    'options' => array(
                                            'label' => 'short',
                                    ),
                                    'attributes'=> array(
                                            'id' => 'textareaId',
                                    ),
                            ));
                            $form->add(array(
                                    'type' => 'Zend\Form\Element\Textarea',
                                    'name' => 'longTxt_'.$detail->getId(),
                                    'options' => array(
                                            'label' => 'long',
                                    ),
                                    'attributes'=> array(
                                            'id' => 'textareaIdLong',
                                    ),
                            ));
                    }

但是如何将db中的值绑定到表单并在提交后解析它? 我想我走错了路:(

0 个答案:

没有答案