2

I have a matrix of checkboxes which I am laying out in a table. I need to pull this matrix into a number of forms, and sometimes multiple times on one form, so I have set it up as a subform.

After much research and deliberation, I decided the best way to decorate the subform was using the viewScript decorator. The code for adding the subform to the form looks something like this:

$this->addSubForm(new Test_Form_Connection_Config_Base(), 'user');
$this->user->setDecorators(array(
    array('viewScript', array('viewScript' => '_forms/userConfig.phtml')),
          'Description',
          'FieldSet',
        ));

For the most part this works fine however the one problem I have is that I can't get array notation to work. Obviously this becomes a problem when I include the matrix more than once on a particular form.

I tried using setIsArray(true) however this had no effefct. It seems that I need to run the FormElements decorator to get the array notation, but this then gives me a duplicate set of fields on the page (rendered once by FormElements, and once by viewScript).

I could manually construct the name of each element to reflect array notation, but this seems like the long way around. Are there any other options that I'm missing?

Thanks...!

1 Answer 1

2

Before using the ViewScript decorator, you should always use the PrepareElements decorator to normalize names.

See http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.prepareElements

Sign up to request clarification or add additional context in comments.

1 Comment

Phil, is there no end to your genius?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.