LegumeType.php 3.62 KB
Newer Older
Mat's avatar
Mat committed
1
2
3
4
5
6
7
<?php

namespace PotageBundle\Form\Legume;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
8
use Symfony\Component\Form\Extension\Core\Type\NumberType;
Mat's avatar
Mat committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use PotageBundle\Entity\Legume;

class LegumeType extends AbstractType
{
    /**
    *
    */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->add('nom', TextType::class, array(
            'label' => "Nom",
25
26
27
28
29
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
                'autofocus' => true,
            ),
Mat's avatar
Mat committed
30
31
32
        ));
        $builder->add('description', TextareaType::class, array(
            'label' => "Description",
33
34
35
36
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
37
38
39
40
        ));
        $builder->add('logoPath', TextType::class, array(
            'required' => false,
            'label' => "Chemin du logo",
41
42
43
44
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
45
46
47
        ));
        $builder->add('unite', TextType::class, array(
            'label' => "Unité",
48
49
50
51
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
52
        ));
53
        $builder->add('quantiteMin', NumberType::class, array(
Mat's avatar
Mat committed
54
            'label' => "Quantité minimale",
55
56
57
58
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
59
        ));
60
        $builder->add('quantiteMax', NumberType::class, array(
Mat's avatar
Mat committed
61
            'label' => "Quantité maximale",
62
63
64
65
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
66
        ));
67
        $builder->add('quantiteStep', NumberType::class, array(
Mat's avatar
Mat committed
68
            'label' => "Écart (step)",
69
70
71
72
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
73
74
75
        ));
        $builder->add('prixUnitaire', MoneyType::class, array(
            'label' => "Prix unitaire",
76
77
78
79
            'label_attr' => array('class' => 'col-sm-4 col-form-label'),
            'attr' => array(
                'class' => 'form-control form-control-sm',
            ),
Mat's avatar
Mat committed
80
81
82
        ));
        $builder->add('sauver', SubmitType::class, array(
            'label' => 'Enregistrer',
83
            'attr' => array('class' => 'btn btn-primary mb-2')
Mat's avatar
Mat committed
84
85
86
87
88
89
90
91
92
93
94
        ));
    }

    /**
    *
    */
    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefault('data_class', Legume::class);
        $resolver->setDefault('attr', array(
95
            'class' => 'formulaire formulaire_legume',
Mat's avatar
Mat committed
96
97
98
99
100
            'novalidate' => true
        ));

    }

101
102
103
104
105
106
107
108
    /**
    *
    */
    public function getBlockPrefix()
    {
        return "legume";
    }

Mat's avatar
Mat committed
109
}