Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you group subforms

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.

like image 409
Jane Yun Avatar asked Feb 23 '11 20:02

Jane Yun


People also ask

How do you refer to a subform?

KEY CONCEPT: When referring to subforms on a main form you will refer to the CONTROL NAME (screenshot says “CONTAINER” but it is the subform control)and not the subform name. Remember that, it is important and it is something that trips up many people when they are trying to figure out why their code isn't working.

How do I create a group in Access form?

Create a custom groupRight-click the top of the Navigation Pane and then select Navigation Options. Select the category for which you want to add one or more groups. For each group, under the Groups for <Group Name> list, click Add Group. Type a name for the new group, and then press ENTER.

How many subforms can a form have?

You can have a maximum Subform depth (Subform within Subform) of 5 and up to 30 Subforms within a Form.


1 Answers

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

like image 75
Jane Yun Avatar answered Oct 19 '22 14:10

Jane Yun