Issue Type: Bug Created: 2010-01-22T05:54:36.000+0000 Last Updated: 2010-01-22T12:45:29.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: Simon Corless (sico) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form
Related issues: Attachments:
As of 1.10.0 it appears that Zend_Validate_Float requires the locale to be either specifically null or a locale. This is all well and good except when used with Zend_Form an empty array is sent to the validator instead of null. Therefore Zend_Validate_Float tries to retrieve the locale 'array' which obviously doesn't exist!
The quick fix is to add a quick empty() check on the $locale and set the locale to null.
The problem occurs when you set messages and pass options into Zend_Form_Element. If there are no options set then nothing is passed to the validator. If only messages are set an empty array is set. If the first element of the array is the value then it all works fine. The first element can be a locale or null and it works as expected.
In short the default null value is being overwritten and the validator requires it to be null when it should be empty.
It worked fine in 1.9.7.
The below code passes an empty array to the validator:
<pre class="highlight"> 'validators' => array( array('Float', true, array('messages' => array( Zend_Validate_Float::NOT_FLOAT => 'The quantity should be a number.', ) ) ) )
The below code works as expected:
<pre class="highlight"> 'validators' => array( array('Float', true, array(null, 'messages' => array( Zend_Validate_Float::NOT_FLOAT => 'The quantity should be a number.', ) ) ) )
Posted by Thomas Weidner (thomas) on 2010-01-22T11:43:20.000+0000
Also before 1.10 Zend_Validate_Float allowed to give a null or a locale.
Posted by Thomas Weidner (thomas) on 2010-01-22T12:45:28.000+0000
Fixed Zend_Form_Element as with r20538
Have you found an issue?
See the Overview section for more details.