4

I'm having difficulty configuring Zend_Form. I have a Zend_Form sub-class. The form has some required information and some additional information. I want the additional information to be accessible via an array. The submitted data will look something like this:

$formData['required1']
$formData['required2']
$formData['addiotnalData']['aData1']
$formData['addiotnalData']['aData2']

I've Googled this and tried all the suggestions I've found (using subForms and setting the Zend_Form::setIsArray($flag) and Zend_Form::setElementsBelongTo($array) methods), but have not figured out how to do this.

What am I doing wrong? How do I set the names of form elements so that I can access the data with array notation?

2 Answers 2

2

Sorted it! The problem is a custom decorator that was being used.

//In
$subForm = new Form_SubForm(); //this can be a Zend_Form or Zend_Form_SubForm     
$subForm->setIsArray(true);
$this->addSubForm($subForm, 'subform');

Elements will be rendered with a id of subform-elementname and a name of subform[elementname].

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

1 Comment

Hi, I have the same problem and made the changes you have told. But this is not working according to my exceptions. what about custom decorators???
0

To expand on the answer because $form->setIsArray(TRUE) was not working with my custom decorator for elements. My custom ViewScript decorator was needed for rendering the Zend_Form_Element.

The problem, it was rendering the element name with $this->element->getName(). I had to use $this->element->getFullyQualifiedName() in the ViewScript decorator script.

Comments

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.