问题描述
我在配置 Zend_Form 时遇到困难.我有一个 Zend_Form 子类.该表格包含一些必需信息和一些附加信息.我希望可以通过数组访问附加信息.提交的数据看起来像这样:
I'm having difficulty configuring Zend_Form. I have a Zend_Form sub-class. The form has some required information and some additional information. I want the additional information to be accessible via an array. The submitted data will look something like this:
$formData['required1']
$formData['required2']
$formData['addiotnalData']['aData1']
$formData['addiotnalData']['aData2']
我在谷歌上搜索并尝试了我找到的所有建议(使用 subForms 并设置 Zend_Form::setIsArray($flag) 和 Zend_Form::setElementsBelongTo($array) 方法),但还没有想出如何做到这一点.
I've Googled this and tried all the suggestions I've found (using subForms and setting the Zend_Form::setIsArray($flag) and Zend_Form::setElementsBelongTo($array) methods), but have not figured out how to do this.
我做错了什么?如何设置表单元素的名称,以便我可以使用数组表示法访问数据?
What am I doing wrong? How do I set the names of form elements so that I can access the data with array notation?
推荐答案
已排序!问题是正在使用的自定义装饰器.
Sorted it! The problem is a custom decorator that was being used.
//In
$subForm = new Form_SubForm(); //this can be a Zend_Form or Zend_Form_SubForm
$subForm->setIsArray(true);
$this->addSubForm($subForm, 'subform');
元素将以 subform-elementname 的 id 和 subform[elementname] 的名称呈现.
Elements will be rendered with a id of subform-elementname and a name of subform[elementname].
这篇关于如何配置 Zend_Form 以使用数组表示法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)