Issues

ZF-5764: Zend_Form should note that '0' value is valid since 1.7 even with required=>true and notEmpty validator

Issue Type: Docs: Improvement Created: 2009-02-12T14:00:46.000+0000 Last Updated: 2010-03-04T09:27:04.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Julian Davchev (jmut) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: - ZF-8938

Attachments:

Description

Since 1.7 (I think) when creating form element and setting value 0 it will pass the notEmpty and required=>true validator. 0 is now considered valid value. Now one should enter empty string instead. I am not 100% if this is all 1.7 issue but on 1.6.2 '0' was not valid with above validators.

Comments

Posted by Dan Entous (dan_nl) on 2009-08-22T08:36:59.000+0000

I also found this to be confusing ... I think the main issue here is what do NotEmtpy and Required mean in regards to a form value?

According to the PHP manual the function empty, considers the value 0 as empty; 0.0 is also considered empty although it's not stated in the manual.

In a form, the value 0 or 0.0 could be considered a value, which is the way the validation works at the moment and seems to make sense in regards to a form value.

I agree with Julian, the manual should state that the NotEmpty and Required validators consider the value 0 as a valid value and NotEmpty should not be confused with the PHP function empty().

Along this same topic, I also found it confusing when using the NotEmpty validator with a Zend_Form_Element. The documentation at 59.2.20. states that NotEmpty Returns TRUE if and only if $value is not an empty value. Yet the default value for the Zend_Form_Element _allowEmpty is true, which cancels out the NotEmpty validator. One could setAllowEmtpy to false along with setting the NotEmpty validator for the field, but it seems that it would make more sense to just use setRequired(true).

Posted by Thomas Weidner (thomas) on 2009-12-08T12:01:19.000+0000

Added with r19353

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