I have an entity field in my form that shows all forms in the database in a list. These forms have revision numbers. What I want to do is to show only the last revision of a form as an option in the list.
To clarify, the form table looks like this
Id || Name || Revision_number
1 || Form1 || 1
2 || Form1 || 2
The select list should only show revision 2.
So far, I have tried this
->add('form', 'entity', array(
'class' => 'AppBundle\Entity\Form',
'label' => 'label.ship.form',
'query_builder' => function(EntityRepository $er){
return $er->createQueryBuilder('f')
->select('f, MAX(f.revisionNumber) AS max_revision');
}
))
But I get this error
Warning: spl_object_hash() expects parameter 1 to be object, string given