How is the best way to add select with choices to filters in Sonata Admin?
For form i can:
$builder->add('gender', 'choice', array( 'choices' => array('m' => 'Male', 'f' => 'Female'), 'required' => false, ));
but this not working in filters.
Advertisement
Answer
For your admin class you should use configureDatagridFilters
function to add your filters,if you want to add custom options for your gender
fields you can use doctrine_orm_string
and provide your choices list in array form
$datagridMapper ->add('gender', 'doctrine_orm_string', array(), 'choice', array('choices' => array('m' => 'Male', 'f' => 'Female') ) );