I need to know whats the usual way to handle datetime via forms.
I have a property in my entity like
/**
* @var \DateTime
*
* @ORM\Column(name="founded", type="datetime", nullable=true)
*/
private $founded;
Then i render the form via FormTypes
->add('founded', 'date', array('widget' => 'single_text', 'format' => 'dd.MM.yyyy'))
The user then inputs a string like 01.01.1892 And sends it to the server via ajax:
form_team[basicdata][founded]:01.01.1914
In the controller i process the data and validate it:
$form = $this->createForm(new TeamsType(), $team);
$form->submit($this->getRequest()->request->get($form->getName()));
if ($form->isValid()) {
...
The thing is, that validation allways fails with: This value is not valid. I guess a datetime object is expected, but the client just delivers a string.
How is that workflow supposed to be working? Please help me with that :)