]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/GroupBundle/Form/GroupType.php
First draft to manage relation between User and Group
[github/wallabag/wallabag.git] / src / Wallabag / GroupBundle / Form / GroupType.php
1 <?php
2
3 namespace Wallabag\GroupBundle\Form;
4
5 use Symfony\Bridge\Doctrine\Form\Type\EntityType;
6 use Symfony\Component\Form\AbstractType;
7 use Symfony\Component\Form\FormBuilderInterface;
8 use Symfony\Component\OptionsResolver\OptionsResolver;
9 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
10 use Symfony\Component\Form\Extension\Core\Type\TextType;
11
12 class GroupType extends AbstractType
13 {
14 /**
15 * @param FormBuilderInterface $builder
16 * @param array $options
17 */
18 public function buildForm(FormBuilderInterface $builder, array $options)
19 {
20 $builder
21 ->add('name', TextType::class, [
22 'required' => false,
23 'label' => 'group.form.name_label',
24 ])
25 ->add('users', EntityType::class, array(
26 'class' => 'WallabagUserBundle:User',
27 'choice_label' => 'username',
28 'multiple' => true,
29 'expanded' => true,
30 ))
31 ->add('save', SubmitType::class, [
32 'label' => 'group.form.save',
33 ])
34 ;
35 }
36
37 /**
38 * @param OptionsResolver $resolver
39 */
40 public function configureOptions(OptionsResolver $resolver)
41 {
42 $resolver->setDefaults(array(
43 'data_class' => 'Wallabag\GroupBundle\Entity\Group',
44 ));
45 }
46 }