简体   繁体   中英

Customise date range field Sonata Admin

I have doctrine_orm_date_range field with standart labels (start date and end date). How can i customise labels?

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

You can try this with datapicker plugin installed. For instance:

$datagridMapper

    // ...

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

Or:

$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'
    ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM