views:

24

answers:

1

I have a simple form accomplished with Zend_Form which is retrieving all its parameters from an XML file. Form has a file input which I need to allow empty submits as well. I mean users should have the chance to leave this field empty.

I tried various combinations of allowEmpty and required directives but no help. Below is the XML block generating the field. Thank you for your help..

<image1Filename type="file">
                <options label="Some Input" allowEmpty="true" required="false" destination="images/cups">
                    <validators>
                        <Size validator="Size">
                            <options value="102400"/>
                        </Size>
                        <Extension validator="Extension">
                            <options value="jpg,png,gif"/>
                        </Extension>
                    </validators>
                </options>
            </image1Filename>
+1  A: 

You should add:

<required>false</required> 

inside the

<options>

In your example it should be:

<image1Filename type="file">
            <options label="Some Input" allowEmpty="true" required="false" destination="images/cups">
                <validators>
                    <Size validator="Size">
                        <options value="102400"/>
                    </Size>
                    <Extension validator="Extension">
                        <options value="jpg,png,gif"/>
                    </Extension>
                </validators>
                <required>false</required> <!-- <<< here -->
            </options>
        </image1Filename>
bas
It's not working :( Any ideas? I keep on receiving the same message "... is not uploaded". ZF version is 1.9.1.This required=false issue troubles me every time :)
Gokcen
Does it make a difference if you disable/remove validators?
bas