如何对子表单进行分组
我在一个表单中有 4 个子表单,我想将其中 2 个组合在一起,然后对它们应用一些装饰器。
这是我到目前为止所拥有的。在每个子表单中,我已经有一些显示组,
$this->setSubForms(array(
'sub1' => $sub1,
'sub2' => $sub2,
'sub3' => $sub3,
'sub4' => $sub4
));
我想我可以做一些类似的事情
$set1 = $this->setSubFormDecorators(array(
'sub1' => $sub1,
'sub2' => $sub2
));
$set1->setDecorator(array('something here'));
$set2 = $this->setSubFormDecorators(array(
'sub3' => $sub3,
'sub4' => $sub4
));
$set2->setDecorator(array('something here'));
,显然这根本不起作用。
我在ZF的文档中确实找不到任何内容。我想如果其他人也遇到过这个困境,我会将其发布在这里。
i have 4 subforms in a form i would like to group 2 of them together, and then apply some decorators to them.
here is what i have so far. w/in each subform i already have some display groups present
$this->setSubForms(array(
'sub1' => $sub1,
'sub2' => $sub2,
'sub3' => $sub3,
'sub4' => $sub4
));
i thought i could do something like
$set1 = $this->setSubFormDecorators(array(
'sub1' => $sub1,
'sub2' => $sub2
));
$set1->setDecorator(array('something here'));
$set2 = $this->setSubFormDecorators(array(
'sub3' => $sub3,
'sub4' => $sub4
));
$set2->setDecorator(array('something here'));
obviously this doesn't work at all.
I really couldn't find anything in ZF's documentation. I thought i post it here if anyone else has run across this quandary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以基本上我已经弄清楚了。
首先,您创建“空”子表单
,然后在该“子表单”中添加所需的子表单,
对要添加装饰器的其他子表单执行相同的操作。
然后在您的原始表单中添加这些新的“$left”和“$right”子表单,
然后您可以根据需要将装饰器应用于“$left”和“$right”子表单。
因为我想删除封装其中元素的字段集
我的看起来像这样,你对另一个也做同样的事情。
谢谢
so basically i've figured it out.
first off you create "empty" subforms
then you add the subforms you want inside of this "subform"
you do the same thing for the other subform you want to add decorators to.
then to your original form you add these new "$left" and "$right" subforms
you can then apply decorators to the "$left" and "$right" subforms as you see fit.
since i want to drop the fieldsets that encapsulate the elements inside
mine looks like this, you do the same to the other one.
Thanks
也许在这种情况下
addDisplayGroup
也可以?Maybe
addDisplayGroup
will be fine in this case too?