Sub forms that have an element the same as their name

2 messages Options
Embed this post
Permalink
josh.ribakoff

Sub forms that have an element the same as their name

Reply Threaded More More options
Print post
Permalink

I checked

23.4.4. Sub Forms


and it said " the master form object will have no awareness of the elements in sub forms. ", am I mis-understanding? Or is the documentation not to be taken literally or something?


http://framework.zend.com/issues/browse/ZF-6480

If you have an object of class Zend_Form called $parent_form for instance, and an object of Zend_Form_SubForm called $child_form, then you add an element called 'foo' to the $child_form, then add $child_form to the $parent_form with the sub-form name 'foo', it does not work

I read in the documentation you cannot have 2 elements in the same form with the same name, for instance you could not add the element and the sub-form to the parent form with the same name, but I cannot find in the documentation where it discusses the behavior I described in that ticket?


Thank you

Josh Ribakoff
josh.ribakoff

Re: Sub forms that have an element the same as their name

Reply Threaded More More options
Print post
Permalink
The issue is specifically that if you have some forms with the following structure ( hopefully ascii formatting is preserved )

$_POST
|
|___ [ 'form']
      |
      |___[ 'element' ] // a sub-form name of element
            |
            |___[ 'element' ] // an element with the name element

now if $_POST['form'] corresponds to $form, and $_POST['form']['element'] corresponds to $form->getSubForm( 'element' ),

I understand that:

the sub-form needs to be able to validate off $_POST as well as $_POST['form']['element']

It uses the dissolveArray and belongsTo features to get at the array located at $_POST['parent_form']['child_form']


but the current implementation backfires, since the sub-form is an "isArray" form, the dissolveArrayValue() method does not work as intended,

when passing $_POST['form']['element'] the above array structure to isValid() method, the Zend_Form component "thinks" the array key in the $data array for the element ( which contains a string ) is actually $_POST['form']['element'] ( which is already assigned to $data within the scope of that method )

Matthew wrote "Not going to fix.

We use array access and overloading within Zend_Form, and use it to pull elements, display groups, and sub forms. As such, sub form names and element names must be unique even between the types."

which confuses me because it doesnt even sound like were talking about the same thing,

Did I find a bug or am I being dense?




Matthew's response was

"We use array access and overloading within Zend_Form, and use it to pull elements, display groups, and sub forms. As such, sub form names and element names must be unique even between the types."


josh.ribakoff wrote:

http://framework.zend.com/issues/browse/ZF-6480

If you have an object of class Zend_Form called $parent_form for instance,
and an object of Zend_Form_SubForm called $child_form, then you add an
element called 'foo' to the $child_form, then add $child_form to the
$parent_form with the sub-form name 'foo', it does not work