添加多个相同类型的子表单
我最近正在使用表单和子表单。
我创建了以下内容:
$form = new Application_Form_Cv();
$experience = new Zend_Form_SubForm();
$form->addSubForm($experience, 'experience');
并且我的数组中确实有一个元素 'experience'
感谢
$form->addSubForm($experience, 'experience');.
当我尝试以下操作时:
$experience->addSubForm(new Application_Form_Experience(), '0');
$experience->addSubForm(new Application_Form_Experience(), '1');
该对象会覆盖自身,我只得到一个 'experience' 元素和 0 和1 不存在。
array (
'controller' => 'cv',
'action' => 'index',
'module' => 'default',
'CvName' => 'Cv Ingenieur informatique',
'LanguageCode' => 'fr',
'UserID' => '2',
'experience' =>
array (
'CompanyName' => 'Mondial Assistance Ltd',
'From' => '2002',
'Until' => '2009',
'Current' => '1',
),
'submit' => 'Save CV',
)
只有 Zend_Form_Subforms
在数组中创建新键?
I'm working with forms and sub forms lately.
I've created the following:
$form = new Application_Form_Cv();
$experience = new Zend_Form_SubForm();
$form->addSubForm($experience, 'experience');
and I do have in my array an element 'experience'
thanks to
$form->addSubForm($experience, 'experience');.
When I try the following:
$experience->addSubForm(new Application_Form_Experience(), '0');
$experience->addSubForm(new Application_Form_Experience(), '1');
The object overwrites itself and I get only one 'experience' element and 0 and 1 are not present.
array (
'controller' => 'cv',
'action' => 'index',
'module' => 'default',
'CvName' => 'Cv Ingenieur informatique',
'LanguageCode' => 'fr',
'UserID' => '2',
'experience' =>
array (
'CompanyName' => 'Mondial Assistance Ltd',
'From' => '2002',
'Until' => '2009',
'Current' => '1',
),
'submit' => 'Save CV',
)
Only Zend_Form_Subforms
creates new keys in an array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下片段应该按预期工作
The following snipped should work as expected