Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SomeType
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $model = $builder->getData();
- $builder
- ->add('someField', null, [
- 'label' => 'Some Field',
- 'choice_label' => 'name',
- 'disabled' => $options['preview_only'],
- 'attr' => [
- 'tabindex' => 8
- ],
- 'query_builder' => function (EntityRepository $er) use ($model){
- $id = $model->getRelatedEntity()->getId();
- $q = 'u.isDeleted = 0';
- $q = $id ? $q.' OR u.id = '.$id : $q;
- return $er->createQueryBuilder('u')->where($q);
- },
- 'choice_attr' => function($val, $key, $index) {
- return $val->getIsDeleted() ? ['disabled' => 'disabled'] : [];
- },
- ])
- }
- //MagicType
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $model = $builder->getData();
- $builder
- ->add('someMagicField', null, [
- 'label' => 'Magic Field',
- 'choice_label' => 'name',
- 'disabled' => $options['preview_only'],
- 'attr' => [
- 'tabindex' => 8
- ],
- 'query_builder' => function (EntityRepository $er) use ($model){
- $id = $model->getRelatedEntity()->getId();
- $q = 'u.isDeleted = 0';
- $q = $id ? $q.' OR u.id = '.$id : $q;
- return $er->createQueryBuilder('u')->where($q);
- },
- 'choice_attr' => function($val, $key, $index) {
- return $val->getIsDeleted() ? ['disabled' => 'disabled'] : [];
- },
- ])
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement