In my symfony form i have a datetime field that looks as follows:
->add('fromTime','datetime', array('label' => 'From ', 'required' => false))
The field should validate with the default value, no matter if that is an empty value or some arbitrary default.
On my localhost there is no problem, even when i leave the field empty the form validation still passes. However, after deploying the website to the server, it turned out that the validation fails with the message "This value is not valid."
As a first solution i tried to add a default value, so the datetime field never has an empty value:
->add('fromTime','datetime', array('data' => new \DateTime('now'), 'label' => 'From ', 'required' => false))
However, again this works perfectly on the localhost (dev and prod environment), but on the server it is completely ignored and the default empty value stays and fails validation.
Does anybody have any idea how i can get an empty value to pass validation on the server, or how i can get a default value set that passes the validation on the server?
Aucun commentaire:
Enregistrer un commentaire