开发者

Allow empty file inputs in Zend_Form

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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜