Skip to content

Instantly share code, notes, and snippets.

@livsi
Last active April 6, 2018 13:15
Show Gist options
  • Select an option

  • Save livsi/9cd7629ba2ea3670f86ec2fc0f4614e9 to your computer and use it in GitHub Desktop.

Select an option

Save livsi/9cd7629ba2ea3670f86ec2fc0f4614e9 to your computer and use it in GitHub Desktop.
sonata date range field and fixed choice list
<?php
....
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$keys = [1,2,3];
$choiceOptions = array_combine(keys, keys);
$datagridMapper
->add('fooType', null, ['show_filter' => true], 'choice', ['choices' => $choiceOptions])
->add('bazType', 'doctrine_orm_date_range', array(
'label' => 'Date',
'field_type' => 'sonata_type_date_range_picker',
'show_filter' => true,
'field_options' => [
'field_options' => [
'format' => 'yyyy-MM-dd',
],
]
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment