ZF-3808: Zend_Filter_Null - converts zero to null
Description
In many situations when you work with database and selecting some value from combobox (Zend_Form_Element_Select) - you need transform the "0 => '-- no value --'" to null to be compatible with database reference integrity. Therefore there should be Zend_Filter_Null for such purpose. I suggest test value for empty() and return null
Comments
Posted by Thomas Weidner (thomas) on 2009-07-09T04:54:29.000+0000
Proposal added and waiting for recommendation from the devteam since 19.06.2009
Posted by Ramon Henrique Ornelas (ramon) on 2009-08-03T10:39:00.000+0000
I had this same problem, first built a filter Null.
But thought best and construct filter DefaultValue.
I think that this case.
code example simple in the class Filter_DefaultValue
__construct( $defaultValue = null );
filter($value) { return $defaultValue; }
Posted by Thomas Weidner (thomas) on 2009-08-03T11:17:40.000+0000
This does not work for the above described case. A "true" would in your case return "null" which is not wished behaviour.
Posted by Ramon Henrique Ornelas (ramon) on 2009-08-03T18:49:52.000+0000
sorry me, just gave a simple example.
I had the same problem in my Applications, this filter that built, solved my problem
call
Zend_Filter::get( 'test' , 'DefaultValue' , array( null , 'test' ) )
Posted by Thomas Weidner (thomas) on 2009-09-14T14:21:41.000+0000
Closing as "Needs proposal". Proposal has been accepted New component within incubator waiting for acceptance to core since 14.09.2009.