I'm using Sonata to render a listing page for an entity.
I want to filter results using one of the columns that holds a date and time. I want to use date picker for better UX. My problem is that none of the official filter types support a single date picker field .
If you will scroll to section 5.1 the documentation gives a bunch of options:
5.1. AVAILABLE FILTER TYPES
For now, only Doctrine ORM filters are available: (...)
but none is able to render a single input. Always a range made of 2 inputs is rendered - I don't need that. I just need a single field.
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('dateStart', 'NONE_OF_THE_TYPES_GIVE_ME_A_SINGLE_PICKER_INPUT', [
// other args
]);
}
Am I missing something? Thanks.
The following worked for me:
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('date', 'doctrine_orm_datetime', [
'label' => 'Date',
'field_type' => 'sonata_type_datetime_picker',
'field_options' => [
'widget' => 'single_text',
]
]);
}
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.