如何对子表单进行分组

发布于 2024-10-19 01:53:01 字数 683 浏览 4 评论 0原文

我在一个表单中有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风透绣罗衣 2024-10-26 01:53:02

所以基本上我已经弄清楚了。

首先,您创建“空”子表单

$left = new Zend_Form_SubForm();     

,然后在该“子表单”中添加所需的子表单,

$left->setSubForms(array(
   'sub1'  => $sub1,
   'sub2'  => $sub2
));

对要添加装饰器的其他子表单执行相同的操作。

$right = new Zend_Form_SubForm();     

$right->setSubForms(array(
   'sub3'  => $sub3,
   'sub4'  => $sub4
));

然后在您的原始表单中添加这些新的“$left”和“$right”子表单,

$this->setSubForms(array(
   'left'  => $left,
   'right' => $right
));

然后您可以根据需要将装饰器应用于“$left”和“$right”子表单。

因为我想删除封装其中元素的字段集
我的看起来像这样,你对另一个也做同样的事情。

    $left->setDecorators(array(
        'FormElements',
        array('HtmlTag', array('tag' => 'div')),
        ));

谢谢

so basically i've figured it out.

first off you create "empty" subforms

$left = new Zend_Form_SubForm();     

then you add the subforms you want inside of this "subform"

$left->setSubForms(array(
   'sub1'  => $sub1,
   'sub2'  => $sub2
));

you do the same thing for the other subform you want to add decorators to.

$right = new Zend_Form_SubForm();     

$right->setSubForms(array(
   'sub3'  => $sub3,
   'sub4'  => $sub4
));

then to your original form you add these new "$left" and "$right" subforms

$this->setSubForms(array(
   'left'  => $left,
   'right' => $right
));

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.

    $left->setDecorators(array(
        'FormElements',
        array('HtmlTag', array('tag' => 'div')),
        ));

Thanks

神也荒唐 2024-10-26 01:53:02

也许在这种情况下 addDisplayGroup 也可以?

Maybe addDisplayGroup will be fine in this case too?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文