ZF-5935: Zend_Form_Element_File does not include Description decorator


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, 102410242) ->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?


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

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"?

Integrated with r14234