src/Form/BubbleEditType.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\MoneyType;
  5. use Symfony\Component\Form\Extension\Core\Type\PercentType;
  6. use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
  7. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  16. /**
  17.  * BubbleType
  18.  */
  19. class BubbleEditType extends AbstractType
  20. {
  21.     /**
  22.      * buildForm
  23.      *
  24.      * @param  mixed $builder
  25.      * @param  mixed $options
  26.      * @return void
  27.      */
  28.     public function buildForm(FormBuilderInterface $builder, array $options)
  29.     {
  30.         $builder
  31.             -> add('bubble_name'TextType::class, [
  32.                 'attr' => [
  33.                     'class' => 'form-control',
  34.                     'readonly' => true,
  35.                 ],
  36.                 'label' => 'Nom de la bulle'
  37.             ])
  38.             ->add('b_address'TextType::class, [
  39.                 'attr' => [
  40.                     'class' => 'form-control',
  41.                     'readonly' => true,
  42.                 ],
  43.             ])
  44.             ->add('b_postal_code'TextType::class, [
  45.                 'attr' => [
  46.                     'class' => 'form-control',
  47.                     'readonly' => true,
  48.                 ],
  49.             ])
  50.             ->add('b_city_name'TextType::class, [
  51.                 'attr' => [
  52.                     'class' => 'form-control',
  53.                     'readonly' => true,
  54.                 ],
  55.             ])
  56.             ->add('b_country'CountryType::class, [
  57.                 'attr' => [
  58.                     'class' => 'form-control',
  59.                     'readonly' => true,
  60.                     'disabled' => true,
  61.                 ],
  62.                 'data' => 'FR' // Set default country to France
  63.             ])
  64.             ->add('is_qc_updatable'ChoiceType::class, [
  65.                 'choices' => [
  66.                     'Non modifiable' => false,
  67.                     'Modifiable' => true
  68.                 ],
  69.                 'attr' => [
  70.                     'class' => 'form-control',
  71.                     'readonly' => true,
  72.                     'disabled' => true,
  73.                 ],
  74.                 'placeholder' => 'Choisir le mode du contrôle qualité',
  75.             ])
  76.             ->add('stripe_customer_id'TextType::class, [
  77.                 'required' => false,
  78.                 'attr' => [
  79.                     'maxlength' => 30
  80.                 ],
  81.             ])
  82.             ->add('stripe_pay_method_id'TextType::class, [
  83.                 'required' => false,
  84.                 'attr' => [
  85.                     'maxlength' => 30
  86.                 ],
  87.             ])
  88.             ->add('number_credit'NumberType::class, [
  89.                 'required' => false,
  90.                 'constraints' => [
  91.                     new GreaterThanOrEqual(['value' => 0.1]),
  92.                     new Assert\Type(
  93.                         'float',
  94.                         ''
  95.                     ),
  96.                 ]
  97.             ])
  98.             ->add('credit_value'MoneyType::class, [
  99.                 'required' => false,
  100.                 'constraints' => [
  101.                     new GreaterThanOrEqual(['value' => 0.01]),
  102.                     new Assert\Type(
  103.                         'float',
  104.                         ''
  105.                     ),
  106.                 ],
  107.                 'attr' => ['class' => 'input-money']
  108.             ])
  109.             // ->add('ad_valorem', NumberType::class, [
  110.             //     'required' => false,
  111.             //     'constraints' => [
  112.             //         new GreaterThanOrEqual(['value' => 0]),
  113.             //         new Assert\Type(
  114.             //             'float',
  115.             //             ''
  116.             //         ),
  117.             //     ],
  118.             //     'attr' => [
  119.             //         'class' => 'input-advalorem'
  120.             //     ]
  121.             // ])
  122.         ;
  123.     }
  124.     /**
  125.      * configureOptions
  126.      *
  127.      * @param  mixed $resolver
  128.      * @return void
  129.      */
  130.     public function configureOptions(OptionsResolver $resolver)
  131.     {
  132.         $resolver->setDefaults([
  133.             'attr' => [
  134.                 'novalidate' => 'novalidate',
  135.             ]
  136.         ]);
  137.     }
  138. }