【问题标题】:Customise date range field Sonata Admin自定义日期范围字段 Sonata Admin
【发布时间】:2018-07-11 21:08:12
【问题描述】:

我有带有标准标签(开始日期和结束日期)的 doctrine_orm_date_range 字段。如何自定义标签?

->add('creationDate', 'doctrine_orm_date_range',  array('label'  => 'list.creationDate'))

【问题讨论】:

  • 嗨,欢迎来到 SO!您的问题非常不清楚,需要更多解释和上下文。请向我们展示您正在努力实现的目标,并详细说明是什么阻碍了您到达您想要的目标。添加您遇到的任何错误。祝你好运!
  • 我的意思是我需要使用哪些属性来自定义labels? p.s.文档对我没有帮助:(

标签: php symfony filter sonata-admin sonata


【解决方案1】:

您可以在安装了 datapicker 插件的情况下尝试此操作。例如:

$datagridMapper

    // ...

    ->add('startedAt', 'doctrine_orm_date_range', [
        'field_type'                    => 'sonata_type_date_range_picker',
        'label'                         => 'admin.label.started_at',
        'translation_domain'            => 'admin',
    ])

或者:

$datagridMapper

    // ...

    ->add('date', 'doctrine_orm_date_range',[
        'input_type' => 'text',
        'field_options' => [
            'field_options_start' => [
                 'years'  => range(2011,2050),
                 'label' => 'Start Date',
            ],
            'field_options_end' => [
                 'years'  => range(2011,2050),
                 'label' => 'End Date',
            ]
        ],
        'label' => 'Date label'
    ])

【讨论】:

    猜你喜欢
    • 2013-01-04
    • 2021-04-25
    • 2022-06-12
    • 2010-12-12
    • 2015-12-11
    • 2013-09-06
    • 2013-08-31
    • 1970-01-01
    • 2016-06-11
    相关资源
    最近更新 更多