【问题标题】:Symfony 3 join together hours minutes, DateTimeTypeSymfony 3 将小时、分钟、DateTimeType 连接在一起
【发布时间】:2018-09-22 11:02:14
【问题描述】:

我正在使用 Symfony\Component\Form\Extension\Core\Type\DateTimeType; 我希望我的时间字段在同一个下拉选择中显示小时和分钟,如下所示:

00:00
00:30
01:00
01:30
02.00
02:30
03:00
03:30

有什么帮助吗?

【问题讨论】:

  • 您能给我们看看构建表单的代码吗?我很确定 TimeTypewidget 选项设置为 choice 可以完成这项工作。

标签: forms symfony select time


【解决方案1】:

嘿,如果您只想将分钟数设为 00 或 30,您可以在 buildForm 中进行:

->add('myDate', DateTimeType::class, array(
                 'widget'  => 'choice',
                 'minutes' => array(
                                    0,
                                    30
                                     ),
                 'with_seconds' => false
            ))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 2013-06-30
    • 2019-01-05
    • 1970-01-01
    相关资源
    最近更新 更多