aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle/Form
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/GroupBundle/Form')
-rw-r--r--src/Wallabag/GroupBundle/Form/GroupType.php28
-rw-r--r--src/Wallabag/GroupBundle/Form/NewGroupType.php28
-rw-r--r--src/Wallabag/GroupBundle/Form/UserGroupType.php46
3 files changed, 102 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Form/GroupType.php b/src/Wallabag/GroupBundle/Form/GroupType.php
index c2ad764b..c708bdb8 100644
--- a/src/Wallabag/GroupBundle/Form/GroupType.php
+++ b/src/Wallabag/GroupBundle/Form/GroupType.php
@@ -3,10 +3,13 @@
3namespace Wallabag\GroupBundle\Form; 3namespace Wallabag\GroupBundle\Form;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7use Symfony\Component\Form\Extension\Core\Type\PasswordType;
6use Symfony\Component\Form\FormBuilderInterface; 8use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver; 9use Symfony\Component\OptionsResolver\OptionsResolver;
8use Symfony\Component\Form\Extension\Core\Type\SubmitType; 10use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9use Symfony\Component\Form\Extension\Core\Type\TextType; 11use Symfony\Component\Form\Extension\Core\Type\TextType;
12use Wallabag\GroupBundle\Entity\Group;
10 13
11class GroupType extends AbstractType 14class GroupType extends AbstractType
12{ 15{
@@ -21,6 +24,31 @@ class GroupType extends AbstractType
21 'required' => false, 24 'required' => false,
22 'label' => 'group.form.name_label', 25 'label' => 'group.form.name_label',
23 ]) 26 ])
27 ->add('defaultRole', ChoiceType::class, [
28 'label' => 'group.form.role_label',
29 'choices' => [
30 'group.roles.readonly' => Group::ROLE_READ_ONLY,
31 'group.roles.write' => Group::ROLE_WRITE,
32 'group.roles.manage_entries' => Group::ROLE_MANAGE_ENTRIES,
33 'group.roles.manage_users' => Group::ROLE_MANAGE_USERS,
34 'group.roles.admin' => Group::ROLE_ADMIN,
35 ],
36 ])
37 ->add('acceptSystem', ChoiceType::class, [
38 'label' => 'group.form.access_label',
39 'choices' => [
40 'group.access.open' => Group::ACCESS_OPEN,
41 'group.access.request' => Group::ACCESS_REQUEST,
42 'group.access.password' => Group::ACCESS_PASSWORD,
43 'group.access.invitation' => Group::ACCESS_INVITATION_ONLY,
44 'group.access.hidden' => Group::ACCESS_HIDDEN,
45 ],
46 ])
47 ->add('plainPassword', PasswordType::class, [
48 'label' => 'group.form.password_label',
49 'required' => false,
50 'attr' => ['autocomplete' => 'off'],
51 ])
24 ->add('save', SubmitType::class, [ 52 ->add('save', SubmitType::class, [
25 'label' => 'group.form.save', 53 'label' => 'group.form.save',
26 ]) 54 ])
diff --git a/src/Wallabag/GroupBundle/Form/NewGroupType.php b/src/Wallabag/GroupBundle/Form/NewGroupType.php
index 29b20fe0..55eebc46 100644
--- a/src/Wallabag/GroupBundle/Form/NewGroupType.php
+++ b/src/Wallabag/GroupBundle/Form/NewGroupType.php
@@ -3,10 +3,13 @@
3namespace Wallabag\GroupBundle\Form; 3namespace Wallabag\GroupBundle\Form;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7use Symfony\Component\Form\Extension\Core\Type\PasswordType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType; 8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
7use Symfony\Component\Form\Extension\Core\Type\TextType; 9use Symfony\Component\Form\Extension\Core\Type\TextType;
8use Symfony\Component\Form\FormBuilderInterface; 10use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver; 11use Symfony\Component\OptionsResolver\OptionsResolver;
12use Wallabag\GroupBundle\Entity\Group;
10 13
11class NewGroupType extends AbstractType 14class NewGroupType extends AbstractType
12{ 15{
@@ -17,6 +20,31 @@ class NewGroupType extends AbstractType
17 'required' => true, 20 'required' => true,
18 'label' => 'group.form.name_label', 21 'label' => 'group.form.name_label',
19 ]) 22 ])
23 ->add('defaultRole', ChoiceType::class, [
24 'label' => 'group.form.role_label',
25 'choices' => [
26 'group.roles.readonly' => Group::ROLE_READ_ONLY,
27 'group.roles.write' => Group::ROLE_WRITE,
28 'group.roles.manage_entries' => Group::ROLE_MANAGE_ENTRIES,
29 'group.roles.manage_users' => Group::ROLE_MANAGE_USERS,
30 'group.roles.admin' => Group::ROLE_ADMIN,
31 ],
32 ])
33 ->add('acceptSystem', ChoiceType::class, [
34 'label' => 'group.form.access_label',
35 'choices' => [
36 'group.access.open' => Group::ACCESS_OPEN,
37 'group.access.request' => Group::ACCESS_REQUEST,
38 'group.access.password' => Group::ACCESS_PASSWORD,
39 'group.access.invitation' => Group::ACCESS_INVITATION_ONLY,
40 'group.access.hidden' => Group::ACCESS_HIDDEN,
41 ],
42 ])
43 ->add('plainPassword', PasswordType::class, [
44 'label' => 'group.form.password_label',
45 'required' => false,
46 'attr' => ['autocomplete' => 'off'],
47 ])
20 ->add('save', SubmitType::class, [ 48 ->add('save', SubmitType::class, [
21 'label' => 'group.form.save', 49 'label' => 'group.form.save',
22 ]) 50 ])
diff --git a/src/Wallabag/GroupBundle/Form/UserGroupType.php b/src/Wallabag/GroupBundle/Form/UserGroupType.php
new file mode 100644
index 00000000..e8f814e4
--- /dev/null
+++ b/src/Wallabag/GroupBundle/Form/UserGroupType.php
@@ -0,0 +1,46 @@
1<?php
2
3namespace Wallabag\GroupBundle\Form\Type;
4
5use Wallabag\GroupBundle\Entity\Group;
6use Symfony\Component\Form\AbstractType;
7use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
8use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver;
10use Symfony\Component\Form\Extension\Core\Type\SubmitType;
11
12class UserGroupType 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('role', ChoiceType::class, [
22 'label' => 'group.edit_user.role',
23 'choices' => [
24 'group.roles.readonly' => Group::ROLE_READ_ONLY,
25 'group.roles.write' => Group::ROLE_WRITE,
26 'group.roles.manage_prez' => Group::ROLE_MANAGE_PREZ,
27 'group.roles.manage_users' => Group::ROLE_MANAGE_USERS,
28 'group.roles.admin' => Group::ROLE_ADMIN,
29 ],
30 ])
31 ->add('save', SubmitType::class, [
32 'label' => 'user.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' => 'Strut\StrutBundle\Entity\UserGroup',
44 ));
45 }
46}