Hello,
I have two entity.
Event and category. Relation n:1. One category can have many events. Now if I would like edit/add new event, in select list should show only parent category and not all like now.
http://pl.tinypic.com/r/2hp81as/9 should show only Fitness and CrossFitnes.
Maybe I misunderstood, but isn't the purpose of the field to allow the admin to change the category ?
Yes, but there are subcategories and parent categories. The administrator should be able choose the parent categories at adding or edit events.
@Pablossoo you've tried the query_builder options to filter this choices ?
Maybe can help you https://github.com/javiereguiluz/EasyAdminBundle/issues/1145
No i don't tried. Can you show me simple example?
Great, thanks!
I have one problem..
Type error: Argument 2 passed to JavierEguiluz\Bundle\EasyAdminBundle\Form\Type\Configurator\AutocompleteTypeConfigurator::supports() must be of the type array, string given, called in C:\xampp\htdocsframework-standard-edition\vendor\javiereguiluz\easyadmin-bundle\Form\Type\EasyAdminFormType.php on line 66
My YML
fields:
- 'title'
- {property: 'start', type: 'text'}
- {property: 'end', type: 'text'}
- 'allDay'
- {property: 'category', type_options: query_builder: 'FitnesBundle\Repository\CategoryRepository::available'}
- 'user'
- 'max'
Repository
public static function available(CategoryRepository $repository)
{
return $repository->createQueryBuilder('c')
->where("c.enabled IS TRUE")
->orderBy('c.name');
}
where is problem ?
@Pablossoo fix that (missing { ... }):
- { property: 'category', type_options: { query_builder: 'FitnesBundle\Repository\CategoryRepository::available' } }
Thank you! but why this not described in guide? this is very helpful.
Hello @yceruto,
Can pass parameter?