Is the value of your Zend_Dojo_Form_Element_DateTextBox form element set to 11/30/1899?
The issue is actually Dojo related. You are most likely setting the value of the form element to '0000-00-00' using the populate() method of the Zend_Form or the setValue() method of the Zend_Form_Element. It so happens in a PHP/MySQL application, you provide a form field to enter the date to the user. The user supplies null value. You insert or update the record in your database. In the database the value is represented as '0000-00-00'. The next time you provide the form to the user, perhaps a data edit form, you populate the form with the values in the database and the user notices that the value is set to 11/30/1899.
Dojo sets the dateTextBox element's value to '11/30/1899', if you try to set it to '0000-00-00'.
To avoid this issue, before setting the form element's value, check if the date is valid. You can check if a date is valid in one line in your Zend Framework application.
<?php Zend_Date::isDate($myDate); ?>
Here's an snippet of code to illustrate the solution.
$birthdayInModel = $myModel['birthday'];
if (! (Zend_Date::isDate($birthdayInModel)) ) {
$myZendDojoFormElementDateTextBox->setValue('');
}
Post new comment