ZF-5935: Zend_Form_Element_File does not include Description decorator

Issue Type: Improvement Created: 2009-03-04T04:33:31.000+0000 Last Updated: 2009-03-05T23:11:59.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Al James (al.james) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: Attachments:


When creating an instance of Zend_Form_Element_File it does not render a description if set with setDescription.


$image_file = $this->createElement('file', 'image_file') ->setLabel('Image file') ->setDescription('Select a image file to upload a new image. Image should be a gif, jpg or png image, less than 2mb in size.') ->addValidator('Count', false, 1) ->addValidator('Size', false, 1024_1024_2) ->addValidator('Extension', false, 'jpg,png,gif');

Does not display the description.

Looking at for code for Zend_Form_Element_File I can see why:

Line 71:

public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; }

    $decorators = $this->getDecorators();
    if (empty($decorators)) {
             ->addDecorator('HtmlTag', array('tag' => 'dd'))
             ->addDecorator('Label', array('tag' => 'dt'));

Its clear that this element does not get its default decorators from the parent... Any reason why?


Posted by Thomas Weidner (thomas) on 2009-03-05T10:33:41.000+0000

Because files don't have a description until they are uploaded. Feel free to use addDecorator() if you want to use decorators.

Posted by Al James (al.james) on 2009-03-05T15:20:53.000+0000

Hmmm... Why does a file not have a description until its uploaded? What if I want to add a description of the form "Please make your file a jpg,gif or png less that 1mb in size"?

Posted by Thomas Weidner (thomas) on 2009-03-05T23:11:59.000+0000

Integrated with r14234

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.