Issues

ZF-4589: Zend_Form_Element_File has mixed error messages

Issue Type: Bug Created: 2008-10-13T12:16:16.000+0000 Last Updated: 2008-11-13T14:10:17.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Martin Hujer (mhujer) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer

  • Zend_Form

Related issues: - ZF-4411

Attachments:

Description

When I have this form:

<pre class="highlight">
        $form = new Zend_Form();
        $form->setName('upload_form');
        $form->setMethod(Zend_Form::METHOD_POST);
        $form->setEnctype('multipart/form-data');

        $element = new Zend_Form_Element_File('upload_file');
        $element->setLabel('upload_file:')->setRequired(true)
            ->setDestination('C:\Temp')
            ->addFilter(new Zend_Filter_File_Rename('XXX', 'XXX'))
            ;
        $form->addElement($element);

        $element2 = new Zend_Form_Element_File('upload_file2');
        $element2->setLabel('upload_file2:')
            ->setDestination('C:\Temp')
            ->addFilter(new Zend_Filter_File_Rename('XXX', 'XXX'))
            ;
        $form->addElement($element2);
        
        $form->addElement(new Zend_Form_Element_Submit(array(
            'name' => 'Upload',
        )));

        $this->view->form = $form;
        
        if ($this->getRequest()->isPost()) {
            if (!$form->isValid($_POST)) {
                echo "Error";
            }
        }

And I submit it without choosing files, it should show the error message "The file 'upload_file' was not uploaded", but it shows "The file 'upload_file2' was not uploaded" by the first element.

http://tmp.hujer.org/2008/file_element_error.png!

Comments

Posted by Thomas Weidner (thomas) on 2008-10-13T13:25:21.000+0000

Duplication of ZF-4411

Posted by Thomas Weidner (thomas) on 2008-10-23T11:54:52.000+0000

Simply said: You can't set one part of your upload required and the other not. Eighter the uploaded files ARE required or they are not required. And this is the reason why your above example does not work as expected.

Posted by Thomas Weidner (thomas) on 2008-10-24T12:33:33.000+0000

New feature for individual options added. Issue fixed with r12122

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:17.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts