ZF-9386: Zend_Form_Element::setBelongsTo is always filled with $form->getElementsBelongTo() in Decorator_FormElements

Issue Type: Sub-task Created: 2010-03-09T18:39:30.000+0000 Last Updated: 2010-03-18T02:54:20.000+0000 Status: Closed Fix version(s): Reporter: Christian Albrecht (alab) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:


In the Docs…

Zend_Form::setElementsBelongTo($array): Using this method, you can specify the name of an array to which all elements of the form belong. You can determine the name using the getElementsBelongTo() accessor.

Additionally, on the element level, you can specify individual elements may belong to particular arrays using Zend_Form_Element::setBelongsTo() method. To discover what this value is -- whether set explicitly or implicitly via the form -- you may use the getBelongsTo() accessor.

But actually setting belongsTo on the element level in combination with setting elementsBelongTo on the (Sub)Form level discards the element level setting.

<pre class="highlight">
$form = new Zend_Form();

$sub = new Zend_Form_SubForm(
        'elementsBelongTo' => 'subform[elementsBelongTo]',
        'elements' => array(
                'type' => 'Text',
                'name' => 'inputText',
                'options' => array(
                'belongsTo' => 'element[belongsTo]'


renders the input like

<pre class="highlight">

And when setting belongsTo after adding the SubForm to the Form

<pre class="highlight">


<pre class="highlight">


Posted by Christian Albrecht (alab) on 2010-03-09T19:01:22.000+0000

My question is then, what would be the expected value for getBelongsTo()?

1.) form[subform][elementsBelongTo][element][belongsTo][inputText] 2.) form[element][belongsTo][inputText] 3.) element[belongsTo][inputText]

Number 1 is the only one i can think of at the moment how to implement.

Posted by Christian Albrecht (alab) on 2010-03-09T19:03:36.000+0000

I mean because 2 and 3 makes it rather heavy for Zend_Form to populate, getValues and Validate.

Posted by Christian Albrecht (alab) on 2010-03-10T08:20:14.000+0000

The question was wrong asked, it should be what is the expected rendered name for the Element, if it has one.

Posted by Christian Albrecht (alab) on 2010-03-18T02:54:04.000+0000

This is fixed with ZF-9451

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.