How do you group subforms

I have 4 subforms in the form, I would like to group 2 of them together and then apply some decorators to them.

that's what i still have. w / in each subform I already have some displayed groups

$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 does not work at all.

I really could not find anything in the ZF documentation. I thought I would send him here if anyone else came across this predicament.

+7
source share
2 answers

so basically I figured it out.

create empty subforms first

 $left = new Zend_Form_SubForm(); 

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

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

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

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

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

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

you can then apply the decorators to the subforms "$ left" and "$ right", as you wish.

since I want to remove fields that encapsulate elements inside my view looks like this, you do the same with the other.

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

thanks

+4
source

Maybe addDisplayGroup will also be in this case?

0
source

All Articles