aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/AnnotationBundle/Form/NewAnnotationType.php
blob: c73c3ded9041f4eaa5964fa570b57e17f8c9890c (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
<?php

namespace Wallabag\AnnotationBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Wallabag\AnnotationBundle\Entity\Annotation;

class NewAnnotationType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('text', null, [
                'empty_data' => '',
            ])
            ->add('quote', null, [
                'empty_data' => null,
            ])
            ->add('ranges', CollectionType::class, [
                'entry_type' => RangeType::class,
                'allow_add' => true,
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Annotation::class,
        ]);
    }
}