I am using a jQuery datetime picker plugin which returns the value in the following format
2016-10-28 21:00 (Format: YYYY-MM-DD H:i)
Here is how I have defined it in entity
/**
* @ORM\Column(name="preferred_datetime", type="datetime", nullable=false)
*/
private $preferredDateTime;
Here is how I am adding the form element
$builder->add('preferred_datetime', DateTimeType::class, [
'label' => 'Preferred Slot *',
'input' => 'datetime',
'widget' => 'single_text',
'format' => 'y-M-d H:i'
]);
This renders the element correctly, however when I submit the form no matter what input value I give it displays the following form error for this field
This value is not valid
Any pointer on what I am missing here? I want both the date and time in YYYY-MM-DD H:i
format. my only issue is validation.
Thanks.
I got it. Issue was with the format. It worked when I am using following format yyyy-MM-dd HH:mm