ZF-8942: Zend_Form::createElement() doesn't load default decorators -- simple fix included!

Issue Type: Bug Created: 2010-01-26T11:14:27.000+0000 Last Updated: 2012-11-08T19:28:39.000+0000 Status: Resolved Fix version(s): - 1.12.1 (18/Dec/12)

Reporter: Brandon Parise (bparise) Assignee: Frank Brückner (frosch) Tags: - Zend_Form

  • After1.12.0
  • FixForZF1.12.1

Related issues: - ZF-12387

Attachments: - Form.php.patch


Per the API docs, Zend_Form::createElement() should load the default decorators set by Zend_Form::setElementDecorators(). It does not...


<pre class="highlight">
class TestCreateElementForm extends Zend_Form
    public function init()
        // Sets default decorators

        // Add an element directly to the form 
        $this->addElement('text', 'element_1');
        print_r($this->getElement('element_1')->getDecorators()); // This works!

        // This doesn't set the decorators
        $element_2 = $this->createElement('text', 'element_2');
        print_r($element_2->getDecorators()); // Does NOT work


Simple Fix: Move lines 996-10007 in Zend_Form::addElement() to Zend_Form::createElement() line 1066. This won't affect addElement() setting of default decorators because it calls createElement() also.


Posted by Lee Robert (lrobert) on 2012-08-22T13:17:54.000+0000

This issue is still a problem. The docblock on createElement states that it should create a form element with the default decorators but it does not actually produce that result.

Posted by Frank Brückner (frosch) on 2012-08-24T09:17:32.000+0000

Patch and unit test added.

Posted by Rob Allen (rob) on 2012-11-07T21:01:47.000+0000

Is this a BC break? i.e. would someone expect createElement to not set default decorators?

Posted by Frank Brückner (frosch) on 2012-11-08T17:21:21.000+0000

{quote}would someone expect createElement to not set default decorators?{quote} I will expect the described behaviour: ;) {quote}Acts as a factory for creating elements. Elements created with this method will not be attached to the form, but will contain element settings as specified in the form object (including plugin loader prefix paths, default decorators, etc.).{quote}…

Posted by Rob Allen (rob) on 2012-11-08T19:28:39.000+0000

Patch applied to trunk (25116) and release-1.12 (25117)

Have you found an issue?

See the Overview section for more details.


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

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