How to configure the list controller ?

    Title

    This parameter allow you to configure the title displayed on the page.

    builders:
      list:
        params:
          title: List of all movies
    

    Tip
    This field will be parsed by twig so you could use all the power of filters...

    Display

    You can choose the columns to show in your list in your yaml

    builders:
      list:
        params:
          display: [ id, title, is_published, producer, release_date ]
    

    The display parameter accept the name of the columns from your model.

    You can also add columns from one to many relations, for example the producer of the movie. In this case, we try to call __toString method else if you parameter the field getter

    Paginate

    You can define the number of elements you want to display per page, the default value is 10.

    builders:
      list:
        params:
          max_per_page: 5
    

    Overwrite the rendering of a field

    Edit the file : YourBundle/Resources/views/List/index.html

    And for the column title overwrite the Twig Block named list_td_column_title

    {% extends_admingenerated "NamespaceYourBundle:List:index.html.twig" %}
    {% block list_td_column_title %}
        <span style="font-weight:bold">{{ Movie.title }}</span>
    {% endblock %}
    

    Default sort

    You can define the default sort options with the key sort :

    builders:
      list:
        params:
          sort: [ producer.name, DESC ]
    

    With the first argument, the column to sort and the second one optionnal the sorting order ASC or DESC (default: ASC)

    Object actions

    You can set actions for rows. This action will call the defined controller, giving the id of the rows

    builders:
      list:
        params:
          object_actions: 
            edit: ~
    

    Will go to the edit link.

    builders:
      list:
        params:
          object_actions: 
            delete: 
              confirm: Are you sure to delete  ?
    

    Will go to edit if you click ok on the confirm box message, and like you can see in this sample you can use twig power in your confirm message

    The default route for an object action is namespace_prefix _ bundle_name _ action_name

    You can change it passing the option route to your action :

    builders:
      list:
        params:
          object_actions: 
            delete: 
              route: my_custom_route
    

    Actions

    You can set action on the List page. The action will not take params.

    builders:
      list:
        params:
          actions:
            new: ~
    

    The default route for an object action is namespace_prefix _ bundle_name _ action_name

    builders:
      list:
        params:
          actions: 
            new: 
              route: my_custom_route
    

    You can add a confirm message like of the Object actions

    The default label is the name of the action, translated in your language by the catalog Admingenerator

    You can edit it with the label option

    builders:
      list:
        params:
          actions: 
            new: 
              label: Create a movie
    

    And of course, you can translate it using the same translation catalog.

    Edit query

    Because the generated class is extended by a class in your bundle, thanks to generation mecanisme, you can easy open the query in cache and see wich method to overwrite. And if you want to add a filter on your query the good method is getQuery

    Eg :

    The default method is :
    <?php
    protected function getQuery()
    {
        $query = MovieQuery::create();
        
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query;
    }
    
    and you can edit to set :
    <?php
    protected function getQuery()
    {
        $query = MovieQuery::create()
                    ->filterByPublished(true);
        
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query;
    }
    
    The default method is :
    <?php
    protected function getQuery()
    {
        $query = $this->getDoctrine()
                    ->getEntityManager()
                    ->createQueryBuilder()
                    ->select('q')
                    ->from('Namespace\\Movie', 'q');
        
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query->getQuery();
    }
    
    and you can edit to set :
    <?php
    protected function getQuery()
    {
        $query = $this->getDoctrine()
                    ->getEntityManager()
                    ->createQueryBuilder()
                    ->select('q')
                    ->from('Namespace\\Movie', 'q')
                    ->addWhere('q.is_published = :is_published')
                    ->setParameter(':is_published', true);
        
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query->getQuery();
    }
    
    The default method is :
    <?php
    protected function getQuery()
    {
        $query = $this->getDocumentManager()
                      ->createQueryBuilder('Namespace\\Movie');
        
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query->getQuery();
    }
    
    and you can edit to set :
    <?php
    protected function getQuery()
    {
        $query = $this->getDocumentManager()
                      ->createQueryBuilder('Namespace\\Movie')
                      ->field('is_published')
                      ->equals(true);
                      
        $this->processSort($query);
        $this->processFilters($query);
    
        return $query->getQuery();
    }
    

    If you want to have by default all the movies published only.

    Found a typo ? Something is wrong in this documentation ? Just fork and edit it !