Symfony2.8。* DateType HTML5 iphone格式

时间:2016-07-07 12:24:57

标签: ios html5 symfony

我有一个表格,我想使用DateType格式,但我在iPhone / iPad上的结果日期选择器有问题。 (最好使用HTML5日期选择器,因为它在不同设备之间看起来更好)

实体:

/**
 * @ORM\Column(type="date")
 */
private $DateOfBirth;

public function setDateOfBirth($dateOfBirth)
{
    $this->DateOfBirth = $dateOfBirth;

    return $this;
}

public function getDateOfBirth()
{
    return $this->DateOfBirth;
}

表格:

->add('DateOfBirth', new DateType(), array(
    'label' => 'Date of birth',
    'widget' => 'single_text',
    'html5'   => true
))

在Android上它工作正常,在桌面上它在Edge和Chrome中运行良好,但IE和FF无法完成这项工作(但是正确的格式有效)

现在问题在于iPad和iPhone,日期选择器看起来不错,但是以3个字母格式输入月份,这是不被接受的。 什么是解决方案(除了回到jquery datepicker)?

编辑:Form I尝试了几次尝试。

来自Symfony网站的

(结果是dd-MM-yyyy格式的HTML5 datepicker):

->add('DateOfBirth', new DateType(), array(
    'widget' => 'single_text',
    'format' => 'yyyy-MM-dd',
    'label' => 'Date of birth',
))

如Alsatian所建议(结果是输入类型文本):

->add('DateOfBirth', new DateType(), array(
    'label' => 'Date of birth',
    'widget' => 'single_text',
    'html5'   => true,
    'format' => 'MM/dd/yy'
));

1 个答案:

答案 0 :(得分:0)

尝试定义另一种格式。

->add('DateOfBirth', new DateType(), array(
    'label' => 'Date of birth',
    'widget' => 'single_text',
    'html5'   => true,
    'format' => 'MM/dd/yy'
));