Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
orderBy param of find_method in ObjectSelect there's no effect #154
I have this one:
$this->add(array( 'name' => 'accountingItemId', 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'options' => array( 'empty_option' => '', 'object_manager' => $entityManager, 'target_class' => 'AccountingItem\Entity\AccountingItem', 'property' => 'accountingItemName', 'is_method' => false, 'find_method' => array( 'name' => 'findAll', 'params' => array( 'orderBy' => array('accountingItemName' => 'ASC') ) ) ), 'attributes' => array( 'class' => 'span4', ) ));
I can set anything that there's no effect in query. Shouldn't it return an ordered list by that param?
Not really, findAll doesn't take parameters as you can see here.
You can do the findBy with empty criteria array.
'find_method' => array( 'name' => 'findBy', 'params' => array( 'criteria' => array(), 'orderBy' => array('accountingItemName' => 'ASC'), ), ),
or create your own function using a custom repository.
I have a question kind of related to this one. I need to add a criteria for this select but the field is a collection, how can I format it. I have this:
I need to find users with the role technician, but in this way it is not working.
Good catch, @netiul ! What is the actual reason for this behaviour? Why should the
BTW: I used your solution in my blog: http://blog.webdevilopers.net/how-to-use-orderby-param-on-find_method-findall-with-doctrine-objectselect/