aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle/Form/NewGroupType.php
blob: 55eebc46d76ff7e0298018bed9bdaee0cc5ffa25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace Wallabag\GroupBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Wallabag\GroupBundle\Entity\Group;

class NewGroupType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, [
                'required' => true,
                'label' => 'group.form.name_label',
            ])
            ->add('defaultRole', ChoiceType::class, [
                'label' => 'group.form.role_label',
                'choices' => [
                    'group.roles.readonly' => Group::ROLE_READ_ONLY,
                    'group.roles.write' => Group::ROLE_WRITE,
                    'group.roles.manage_entries' => Group::ROLE_MANAGE_ENTRIES,
                    'group.roles.manage_users' => Group::ROLE_MANAGE_USERS,
                    'group.roles.admin' => Group::ROLE_ADMIN,
                ],
            ])
            ->add('acceptSystem', ChoiceType::class, [
                'label' => 'group.form.access_label',
                'choices' => [
                    'group.access.open' => Group::ACCESS_OPEN,
                    'group.access.request' => Group::ACCESS_REQUEST,
                    'group.access.password' => Group::ACCESS_PASSWORD,
                    'group.access.invitation' => Group::ACCESS_INVITATION_ONLY,
                    'group.access.hidden' => Group::ACCESS_HIDDEN,
                ],
            ])
            ->add('plainPassword', PasswordType::class, [
                'label' => 'group.form.password_label',
                'required' => false,
                'attr' => ['autocomplete' => 'off'],
            ])
            ->add('save', SubmitType::class, [
                'label' => 'group.form.save',
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'Wallabag\GroupBundle\Entity\Group',
        ]);
    }

    public function getBlockPrefix()
    {
        return 'new_group';
    }
}