*/
public function buildForm(FormBuilderInterface $builder, array $options): void {
//Add dance field
- $builder->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']]);
+ $builder->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your dance')], 'data' => $options['dance_default']]);
//Add date field
- $builder->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
+ $builder->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(null, 'Please provide your date'), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
//Add location field
- $builder->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'data' => $options['location_default']]);
+ $builder->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your location')], 'data' => $options['location_default']]);
//Add slot field
- $builder->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']]);
+ $builder->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(null, 'Please provide your slot')], 'choice_translation_domain' => true, 'data' => $options['slot_default']]);
//Add extra user field
if (!empty($options['user'])) {
//XXX: choicetype used here to use our own custom translated string
- $builder->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $options['user_choices'], 'data' => $options['user_default']]);
+ $builder->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(null, 'Please provide your user')], 'choices' => $options['user_choices'], 'data' => $options['user_default']]);
}
//Add submit
public function buildForm(FormBuilderInterface $builder, array $options): void {
//Add fields
$builder
- ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]])
- ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]])
- ->add('mail', EmailType::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(['message' => 'Please provide a valid mail']), new Email(['message' => 'Your mail doesn\'t seems to be valid'])]])
- ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]])
+ ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(null, 'Please provide your name')]])
+ ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(null, 'Please provide your subject')]])
+ ->add('mail', EmailType::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(null, 'Please provide a valid mail'), new Email(null, 'Your mail doesn\'t seems to be valid')]])
+ ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(null, 'Please provide your message')]])
->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
//Call parent
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
return $builder
- ->add('offense', ChoiceType::class, ['choices' => ['Forbidden gathering' => 'gathering', 'Traffic at prohibited time' => 'traffic'/*, 'Traffic at prohibited location' => 'location'*/], 'attr' => ['placeholder' => 'Your offense'], 'constraints' => [new NotBlank(['message' => 'Please provide your offense'])]])
- ->add('court', TextType::class, ['label' => 'Court city', 'attr' => ['placeholder' => 'Your court city'], 'constraints' => [new NotBlank(['message' => 'Please provide your court city'])]])
- ->add('notice', TextType::class, ['label' => 'Notice number', 'attr' => ['placeholder' => 'Your notice number'], 'constraints' => [new NotBlank(['message' => 'Please provide your notice'])]])
- ->add('agent', TextType::class, ['label' => 'Agent number', 'attr' => ['placeholder' => 'Your agent number'], 'constraints' => [new NotBlank(['message' => 'Please provide your agent'])]])
- ->add('service', TextType::class, ['label' => 'Service code', 'attr' => ['placeholder' => 'Your service code'], 'constraints' => [new NotBlank(['message' => 'Please provide your service'])]])
+ ->add('offense', ChoiceType::class, ['choices' => ['Forbidden gathering' => 'gathering', 'Traffic at prohibited time' => 'traffic'/*, 'Traffic at prohibited location' => 'location'*/], 'attr' => ['placeholder' => 'Your offense'], 'constraints' => [new NotBlank(null, 'Please provide your offense')]])
+ ->add('court', TextType::class, ['label' => 'Court city', 'attr' => ['placeholder' => 'Your court city'], 'constraints' => [new NotBlank(null, 'Please provide your court city')]])
+ ->add('notice', TextType::class, ['label' => 'Notice number', 'attr' => ['placeholder' => 'Your notice number'], 'constraints' => [new NotBlank(null, 'Please provide your notice')]])
+ ->add('agent', TextType::class, ['label' => 'Agent number', 'attr' => ['placeholder' => 'Your agent number'], 'constraints' => [new NotBlank(null, 'Please provide your agent')]])
+ ->add('service', TextType::class, ['label' => 'Service code', 'attr' => ['placeholder' => 'Your service code'], 'constraints' => [new NotBlank(null, 'Please provide your service')]])
->add('abstract', TextareaType::class, ['attr' => ['placeholder' => 'Your abstract', 'cols' => 50, 'rows' => 15], 'constraints' => []])
->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
}
/**
* {@inheritdoc}
*/
- public function buildForm(FormBuilderInterface $form, array $options): FormBuilderInterface {
+ public function buildForm(FormBuilderInterface $form, array $options): void {
//With location
if ($options['location']) {
$form->add('location', HiddenType::class, ['required' => true]);
//With image
if ($options['image']) {
//With image
- $form->add('image', FileType::class, ['attr' => ['placeholder' => 'Your image'], 'constraints' => [new File(['maxSize' => '5M', 'mimeTypes' => ['image/jpeg', 'image/png', 'image/tiff', 'image/webp'], 'mimeTypesMessage' => 'Please upload a valid Image document'])]/*, 'mapped' => false*/, 'required' => $options['delete'] ? false : true]);
+ $form->add('image', FileType::class, ['attr' => ['placeholder' => 'Your image'], 'constraints' => [new File(null, '5M', null, ['image/jpeg', 'image/png', 'image/tiff', 'image/webp'], null, null, null, null, 'Please upload a valid Image document')]/*, 'mapped' => false*/, 'required' => $options['delete'] ? false : true]);
}
//Add submit
//TODO: add confirm on click ?
$form->add('delete', SubmitType::class, ['label' => 'Delete', 'attr' => ['class' => 'submit']]);
}
-
- //Return form builder
- return $form;
}
/**
public function buildForm(FormBuilderInterface $builder, array $options): void {
//Build form
$builder
- ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(['message' => 'Please provide your title'])]])
+ ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(null, 'Please provide your title')]])
->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false])
- ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(['message' => 'Please provide your address'])]])
- ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your zipcode'])]])
- ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(['message' => 'Please provide your city'])]])
- ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your latitude'])]])
- ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your longitude'])]])
+ ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(null, 'Please provide your address')]])
+ ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(null, 'Please provide your zipcode')]])
+ ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(null, 'Please provide your city')]])
+ ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(null, 'Please provide your latitude')]])
+ ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(null, 'Please provide your longitude')]])
->add('indoor', CheckboxType::class, ['attr' => ['placeholder' => 'Your indoor'], 'required' => false])
->add('hotspot', CheckboxType::class, ['attr' => ['placeholder' => 'Your hotspot'], 'required' => false])
->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
if (!empty($options['admin'])) {
$builder
//Add dance field
- ->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']])
+ ->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your dance')], 'data' => $options['dance_default']])
//Add slot field
- ->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']])
+ ->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(null, 'Please provide your slot')], 'choice_translation_domain' => true, 'data' => $options['slot_default']])
//Add date field
- ->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => $options['date'], 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
+ ->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => $options['date'], 'constraints' => [new NotBlank(null, 'Please provide your date'), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
}
$builder
//TODO: avertissement + minimum et maximum ???
- ->add('begin', TimeType::class, ['attr' => ['placeholder' => 'Your begin', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['begin'], 'constraints' => [new NotBlank(['message' => 'Please provide your begin']), new Type(['type' => \DateTime::class, 'message' => 'Your begin doesn\'t seems to be valid'])]])
+ ->add('begin', TimeType::class, ['attr' => ['placeholder' => 'Your begin', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['begin'], 'constraints' => [new NotBlank(null, 'Please provide your begin'), new Type(['type' => \DateTime::class, 'message' => 'Your begin doesn\'t seems to be valid'])]])
//TODO: avertissement + minimum et maximum ???
- ->add('length', TimeType::class, ['attr' => ['placeholder' => 'Your length', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['length'], 'constraints' => [new NotBlank(['message' => 'Please provide your length']), new Type(['type' => \DateTime::class, 'message' => 'Your length doesn\'t seems to be valid'])]])
+ ->add('length', TimeType::class, ['attr' => ['placeholder' => 'Your length', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['length'], 'constraints' => [new NotBlank(null, 'Please provide your length'), new Type(['type' => \DateTime::class, 'message' => 'Your length doesn\'t seems to be valid'])]])
->add('modify', SubmitType::class, ['label' => 'Modify', 'attr' => ['class' => 'submit']]);
}
$locations = $this->doctrine->getRepository(Location::class)->findComplementBySessionId($options['session']);
$builder
//TODO: class senior en orange ???
- ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'choices' => $locations, 'choice_translation_domain' => true])
+ ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(null, 'Please provide your location')], 'choices' => $locations, 'choice_translation_domain' => true])
->add('move', SubmitType::class, ['label' => 'Move', 'attr' => ['class' => 'submit']]);
}
//Add admin fields
$builder
//TODO: class admin en rouge ???
- ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
+ ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(null, 'Please provide your user')], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
->add('lock', SubmitType::class, ['label' => 'Lock', 'attr' => ['class' => 'submit']]);
//Is admin and locked === null
/**
* {@inheritdoc}
*/
- public function buildForm(FormBuilderInterface $form, array $options): FormBuilderInterface {
+ public function buildForm(FormBuilderInterface $form, array $options): void {
//Start build form
$form
//Add locale, location and user hidden fields
//Add submit
$form->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
-
- //Return form builder
- return $form;
}
/**