[ Symfony2.8.* DateType HTML5 iphone format ]
I have a form where I would like to use the DateType format but I have a problem with the resulting datepicker on iPhone/iPad. (Preferably using the HTML5 datepicker as it looks better between different devices)
The Entity:
/**
* @ORM\Column(type="date")
*/
private $DateOfBirth;
public function setDateOfBirth($dateOfBirth)
{
$this->DateOfBirth = $dateOfBirth;
return $this;
}
public function getDateOfBirth()
{
return $this->DateOfBirth;
}
The form:
->add('DateOfBirth', new DateType(), array(
'label' => 'Date of birth',
'widget' => 'single_text',
'html5' => true
))
On android it works fine, on desktop it works great in Edge and Chrome but IE and FF fail to do the job (but giving the correct format works)
Now the problem is with iPad and iPhone, the datepicker looks good but enters the month in 3-letter format which isn't accepted. What is THE solution to this (besides going back to a jquery datepicker)?
EDIT: Several attempts of Form I tried.
from the Symfony website (result is HTML5 datepicker in dd-MM-yyyy format):
->add('DateOfBirth', new DateType(), array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'label' => 'Date of birth',
))
as suggested by Alsatian (Result is input type Text):
->add('DateOfBirth', new DateType(), array(
'label' => 'Date of birth',
'widget' => 'single_text',
'html5' => true,
'format' => 'MM/dd/yy'
));
Answer 1
Try to define another format.
->add('DateOfBirth', new DateType(), array(
'label' => 'Date of birth',
'widget' => 'single_text',
'html5' => true,
'format' => 'MM/dd/yy'
));