I want to use a script view to render my zend form, as this seems to be the best way to control the layout / design of the form while still using the Zend_Elements classes.
From the script view, I create an element with $this->element->getElement('elementName')
.
I'm having issues with item names. This is actually a sub-form inside a subform inside a form.
When I used FormElements decorators, the full name of the elements was formed [subForm] [subForm] [element], which was good. Wehn I switched to viewScript decorators, it changed to subForm [subForm] [element].
I realized that I needed to use the PrepareElements decorator to fix this, but it made the name change the form [subForm] [form] [subForm] [subForm] [elements] (it doubled the first two names at the beginning).
Any ideas how I should handle this?
Thanks.
UPDATE: I tried to debug PrepareElements, and I really don't understand what it is doing. It seems to work fine in the first iteration, but then it again adds the prefix of the form [subform] when working on one of the middle subforms.
When I do not use the PrepareElements decorator, I simply skip the "form" prefix in the names (that is, instead of the form [subForm] [element], I get only subForm [element]).
Maybe I can somehow fix this?
I tried to change the belongsTo property, but only replaced the prefix "subForm".
Actually, it seems that the applyTo method in subForm is missing.
Again, all this is due to the ViewScript decorator. It works great with FormElements decorators.
UPDATE 2: Just to clarify, I would not mind this name change, but it causes my fields to not populate when I call form-> populate.
Edit: I think I narrowed down the problem: when I return my values โโto setDefaults, they are ordered as follows:
array( \"formElements1-name\" => value1... \"subFormName\" => array( \"parentFormName\" => array( \"subFormName\" => subForm-values-array ) )
... The main problem here is that "parentFormName" => "subFormNAme"..
what does it repeat? I'm already in top form. I suppose this is because I set setElementsBelongTo(formName[subFormName])
, but if I didnโt, then I would get my subform values โโcompletely separate from the form,
i.e. values โโarray = array (\ "formName \" => array (formValues), \ "subFormNAme \" => array (subFormValues)
and I exepct him
array( formName => array( subFormNAme => values-array ) )...
Is it possible to make this work?