Test Failed
Push — develop ( f1bc6f...c58911 )
by Stone
04:52
created

CommentTypeForm::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Form;
4
5
use App\Entity\Comment;
6
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
9
use Symfony\Component\Form\FormBuilderInterface;
10
use Symfony\Component\OptionsResolver\OptionsResolver;
11
12
class CommentTypeForm extends AbstractType{
13
14
    public function buildForm(FormBuilderInterface $builder, array $options)
15
    {
16
        $builder
17
            ->add('comment', TextareaType::class, [
18
                'label' => 'New Comment',
19
                'required' => false,
20
                'attr' => [
21
                    'class' => 'materialize-textarea'
22
                ]
23
            ])
24
            ->add('save', SubmitType::class, [
25
                'label' => $options['save_button_label'],
26
                'attr' => [
27
                    'class' => 'waves-effect waves-light btn right mr-2'
28
                ]
29
            ])
30
        ;
31
    }
32
33
    public function configureOptions(OptionsResolver $resolver)
34
    {
35
        $resolver->setDefaults([
36
            'save_button_label' => 'Save',
37
            'data_class' => Comment::class,
38
            // enable/disable CSRF protection for this form
39
            'csrf_protection' => true,
40
            // the name of the hidden HTML field that stores the token
41
            'csrf_field_name' => '_token',
42
            // an arbitrary string used to generate the value of the token
43
            // using a different string for each form improves its security
44
            'csrf_token_id'   => 'CommentForm',
45
        ]);
46
    }
47
}