symfony - Symfony2 - Give a default filter in a list of elements of Sonata Admin -


i have list of elements of type vehicle , show these elements sonata admin. allow filter these elements "status" field, want that, when list showed, active vehicles showed, , if wants see inactive vehicles, uses filter , select inactive status. know if knows way apply filters default list of elements using sonata admin.

here code:

public function configurelistfields(listmapper $listmapper) {     $listmapper         ->addidentifier('name')         ->add('status')     ; }  protected function configuredatagridfilters(datagridmapper $mapper)  {      $mapper          ->add('name')          ->add('status')      ;  } 

is there option can added status field in configuredatagridfilters() achieve goal? other options?

thanks in advance.

you have override $datagridvalues property following (for status > 0 if it's integer) :

   /**     * default datagrid values     *     * @var array     */    protected $datagridvalues = array (            'status' => array ('type' => 2, 'value' => 0), // type 2 : >            '_page' => 1, // display first page (default = 1)            '_sort_order' => 'desc', // descendant ordering (default = 'asc')            '_sort_by' => 'id' // name of ordered field (default = model id field, if any)       // '_sort_by' key can of form 'mysubmodel.mysubsubmodel.myfield'.    ); 

source : configure default page , ordering in list view


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -