src/Form/CompanyPaymentType.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Company;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  6. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  7. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  8. use Symfony\Component\Form\Extension\Core\Type\DateType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  11. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  12. use Symfony\Component\Form\Extension\Core\Type\FormType;
  13. use Symfony\Component\Form\Extension\Core\Type\FileType;
  14. use Symfony\Component\Form\Extension\Core\Type\TelType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextType;
  16. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  17. use Symfony\Component\Form\FormBuilderInterface;
  18. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  19. use Symfony\Component\OptionsResolver\OptionsResolver;
  20. use Symfony\Component\Validator\Constraints\Length;
  21. use App\Entity\CompanyPayment;
  22. class CompanyPaymentType extends AbstractType
  23. {
  24.     public function buildForm(FormBuilderInterface $builder, array $options)
  25.     {
  26.         $years = array();
  27.         for ($i date('Y'); $i < (date('Y')+10); $i++){
  28.             $years[]=$i;
  29.         }
  30.         $builder
  31.             ->add('type'ChoiceType::class, array(
  32.                 'choices' => array(
  33.                     'Visa' => 0,
  34.                     'MasterCard' => 1,
  35.                     'Amex' => 3
  36.                 )
  37.             ))
  38.             ->add('fullname'TextType::Class, array('label' => 'Nom complet figurant sur la carte'))
  39.             ->add('creditCardNumberHidden'TextType::Class, array(
  40.                 'label' => 'Numéro de carte de crédit',
  41.                 'attr' => array('placeholder' => '0000 0000 0000 0000')
  42.             ))
  43.             ->add('creditCardExpiration'DateType::class, array(
  44.                 'label' => "Date d'expiration",
  45.                 'format' => 'ddMMyyyy',
  46.                 'years' => $years
  47.             ))
  48.             ->add('creditCardCVV'TextType::class, array('label' => 'CVV'))
  49.             ->add('contactName'TextType::class, array(
  50.         'label' => 'Nom de contact pour la facturation',
  51.         'required' => false
  52.          ))
  53.             ->add('save'SubmitType::Class, 
  54.                 array(
  55.                     'label' => 'Enregistrer'    
  56.                 )
  57.             )
  58.         ;
  59.     }
  60.     public function configureOptions(OptionsResolver $resolver)
  61.     {
  62.         $resolver->setDefaults([
  63.             'data_class' => CompanyPayment::class,
  64.         ]);
  65.     }
  66. }