]> Raphaƫl G. Git Repositories - airbundle/blob - Form/ApplicationType.php
Build context in constructor
[airbundle] / Form / ApplicationType.php
1 <?php
2
3 namespace Rapsys\AirBundle\Form;
4
5 use Symfony\Component\Form\AbstractType;
6 use Symfony\Component\Form\FormBuilderInterface;
7 use Symfony\Component\OptionsResolver\OptionsResolver;
8 use Symfony\Bridge\Doctrine\Form\Type\EntityType;
9 use Symfony\Component\Form\Extension\Core\Type\DateType;
10 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
11 use Symfony\Component\Validator\Constraints\Date;
12 use Symfony\Component\Validator\Constraints\NotBlank;
13
14 class ApplicationType extends AbstractType {
15 /**
16 * {@inheritdoc}
17 */
18 public function buildForm(FormBuilderInterface $builder, array $options) {
19 return $builder
20 ->add('location', EntityType::class, array('class' => 'RapsysAirBundle:Location', 'choice_label' => 'title', 'attr' => array('placeholder' => 'Your location'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your location')))))
21 ->add('date', DateType::class, array('attr' => [ 'placeholder' => 'Your date', 'class' => 'date' ], 'html5' => true, 'input' => 'datetime', 'data' => new \DateTime('+7 day'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your date')), new Date(array('message' => 'Your date doesn\'t seems to be valid')))))
22 ->add('slot', EntityType::class, array('class' => 'RapsysAirBundle:Slot', 'choice_label' => 'title', 'attr' => array('placeholder' => 'Your slot'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your slot')))))
23 ->add('submit', SubmitType::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
24 }
25
26 /**
27 * {@inheritdoc}
28 */
29 public function configureOptions(OptionsResolver $resolver) {
30 $resolver->setDefaults(['error_bubbling' => true]);
31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 public function getName() {
37 return 'rapsys_air_application';
38 }
39 }