如何配置Zend_Form使用数组符号? [英] How do configure Zend_Form to use array notation?

查看:64
本文介绍了如何配置Zend_Form使用数组符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在配置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']

我已经对此进行了Google搜索,并尝试了所有发现的建议(使用子窗体并设置了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');

将使用id为subform-elementname且名称为subform[elementname]的元素进行渲染.

Elements will be rendered with a id of subform-elementname and a name of subform[elementname].

这篇关于如何配置Zend_Form使用数组符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆