1
votes

how to set a limt of results with the object image. i just want to have on result for the listmapper.

i know '_sort_by', but does exist a maximun results that i can put to my listmapper ??? thanks

protected function configureListFields(ListMapper $listMapper) {

    $listMapper
        ->addIdentifier('name', null, array('route' => array('name' => 'show')))
        ->add('country')
        ->add('category')
        ->add('description')
        ->add('organisation', null, array('route' => array('name' => 'show')))
        ->add('competition',  null, array('route' => array('name' => 'show')))
        ->add('image')
        ->add('created')
        ->add('updated')
        ->add('_action', null, array(
            'actions' => array(
                'show' => array(),
                'edit' => array(),
                'delete' => array(),
            )
        ))
    ;
}

ps: like add(image', null, array('limit' => 1)) but it's not working

1
Do you know use $this->datagridValues = array( '_page' => 1, '_per_page' => 50, /** '_sort_order' => 'DESC', // sort direction */ ); ? - Imanali Mamadiev
no, it's not working - sorry. I mean, i just want to have 1 entity 'image' from this list mapper - olivier toppin

1 Answers

1
votes

You can use the method createQuery() to change the query used to generate the list, here is an example :

class YourAdmin extends AbstractAdmin {

    // ...

    public function createQuery($context = 'list')
    {
       $query = parent::createQuery($context);
       $query
           ->setFirstResult( $offset )
           ->setMaxResults( $limit )
       ;
       return $query;
    }

    // ...
}