Emerick
Emerick

Reputation: 120

symfony doctrine admin generator -> custom listing

I haven't found a way yet to customize what items are shown in the "list" view. To be a little bit more specific : by default all the records in a database table are selected and displayed, I want to be able to tweak a little the database select in order to select only a subset of items from the table.

Upvotes: 1

Views: 1306

Answers (3)

Dziamid
Dziamid

Reputation: 11581

config:
  list:
    table_method: getForAdminList

Then, in a related model table class you can define your conditions to filter records:

  public function getForAdminList()
  {        
    $q = $this->createQuery('a')
      ->where('a.id > ?', 100);
    return $q;
  }

Notice that you have to return the query, not a collection of records.

Upvotes: 5

Pabloks
Pabloks

Reputation: 1484

In /backend/modules/*module_name*/actions/action.class.php you can override the default admin methods of that module (like in frontend). If you want to filter all querys you can override the getFilters() method and add the default param like:

class firmaActions extends autoFirmaActions
{
    protected function getFilters(){
        $filters = parent::getFilters();
        $filters['level_id'] = '3';
        return $filters;
    }
}

If you want to take a look of autoModuleActions you can find it in cache/backend/modules/autoModule/actions

Upvotes: 0

Blair McMillan
Blair McMillan

Reputation: 5349

Typically you wouldn't modify the DB call, but would instead change what is shown by editing the generator.yml file.

The part you should be interested in is

config:
  list:
    display: [fields, to, display]

Upvotes: 0

Related Questions