src/Form/WarrantyType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Warranty;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  10. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  11. use Symfony\Component\Form\Extension\Core\Type\DateType;
  12. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  13. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  14. use Symfony\Component\HttpFoundation\RequestStack;
  15. class WarrantyType extends AbstractType
  16. {
  17.     private $requestStack;
  18.     public function __constructRequestStack $requestStack 
  19.     {
  20.         $this->requestStack $requestStack;
  21.     } 
  22.     public function buildForm(FormBuilderInterface $builder, array $options)
  23.     {
  24.         $builder
  25.             ->add('serialNumber'TextType::class, [
  26.                 'label' => 'CoaguChek<sup>®</sup> INRange serial #*:',
  27.                 'label_html' => true,
  28.                 'label_attr' => ['class' => 'info'],
  29.                 'help' => 'The serial number is on the back of the meter above the barcode.'
  30.             ])
  31.             ->add('dateOfPurchase'DateType::class, [
  32.                 'widget' => 'single_text',
  33.                 'format' => 'yyyy-MM-dd',
  34.                 'attr' => [
  35.                     'autocomplete' => 'off'
  36.                 ],
  37.                 'label' => 'Date of purchase*:'
  38.             ])
  39.             ->add('firstname'TextType::class, [
  40.                 'label' => 'First name*:'
  41.             ])
  42.             ->add('lastname'TextType::class, [
  43.                 'label' => 'Last name*:'
  44.             ])
  45.             ->add('dateOfBirth'DateType::class, [
  46.                 'widget' => 'single_text',
  47.                 'format' => 'yyyy-MM-dd',
  48.                 'attr' => [
  49.                     'autocomplete' => 'off'
  50.                 ],
  51.                 'label' => 'Date of birth*:'
  52.             ])
  53.             ->add('inrSelfTesting'ChoiceType::class, [
  54.                 'choices' => [
  55.                     'Yes' => 'yes',
  56.                     'No' => 'no'
  57.                 ],
  58.                 'expanded' => true,
  59.                 'multiple' => false,
  60.                 'label' => 'Is this meter for your own use to do INR self-testing?*',
  61.                 'attr' => ['class' => 'form-check-inline'],
  62.             ])
  63.             ->add('purpose'TextType::class, [
  64.                 'label' => 'If no, how will you use this meter?',
  65.                 'required'   => false
  66.             ])
  67.             ->add('healthcareProfessional'ChoiceType::class, [
  68.                 'choices' => [
  69.                     'Yes' => 'yes',
  70.                     'No' => 'no'
  71.                 ],
  72.                 'attr' => ['class' => 'form-check-inline'],
  73.                 'expanded' => true,
  74.                 'multiple' => false,
  75.                 'label' => 'Are you a healthcare professional?*'
  76.             ])
  77.             ->add('profession'TextType::class, [
  78.                 'label' => 'If yes, please indicate profession',
  79.                 'required'   => false
  80.             ])
  81.             ->add('street'TextType::class, [
  82.                 'label' => 'Street*:'
  83.             ])
  84.             ->add('unit'TextType::class, [
  85.                 'label' => 'Unit:',
  86.                 'required'   => false
  87.             ])
  88.             ->add('city'TextType::class, [
  89.                 'label' => 'City*:'
  90.             ])
  91.             ->add('postalCode'TextType::class, [
  92.                 'label' => 'Postal code*:'
  93.             ])
  94.             ->add('phone'TextType::class, [
  95.                 'label' => 'Phone*:'
  96.             ])
  97.             ->add('email'EmailType::class, [
  98.                 'label' => 'Email*:'
  99.             ])
  100.             ->add('language'ChoiceType::class, [
  101.                 'choices' => [
  102.                     'English' => 'english',
  103.                     'French' => 'french'
  104.                 ],
  105.                 'expanded' => true,
  106.                 'multiple' => false,
  107.                 'label' => 'Language*:'
  108.             ])
  109.             ->add('declarationPrescription'CheckboxType::class, [
  110.                 'label' => 'I am aware that a prescription is required for a patient to have INR testing done with the CoaguChek<sup>®</sup> INRange system.',
  111.                 'label_html' => true,
  112.                 'required' => false
  113.             ])
  114.             ->add('declarationTestLimitation'CheckboxType::class, [
  115.                 'label' => 'I am aware of the test limitations and interferences of the CoaguChek<sup>®</sup> INRange system (refer to the Product Insert found in the CoaguChek<sup>®</sup> INRange test strip box).',
  116.                 'label_html' => true,
  117.                 'required' => false
  118.             ])
  119.             ->add('declarationCorrectly'CheckboxType::class, [
  120.                 'label' => 'I can use the CoaguChek<sup>®</sup> INRange meter correctly to obtain a coagulation result.',
  121.                 'label_html' => true,
  122.                 'required' => false
  123.             ])
  124.             ->add('declarationQuestions'CheckboxType::class, [
  125.                 'label' => 'If I have any questions, I can obtain training information available on the website (www.coaguchek.ca) and at the Coagulation Info-Line at 1-877-426-2482.',
  126.                 'required' => false
  127.             ])
  128.             ->add('declarationCommunications'CheckboxType::class, [
  129.                 'label' => 'I would like to receive communications from Roche such as CoaguChek<sup>®</sup> product news and promotions',
  130.                 'label_html' => true,
  131.                 'required' => false
  132.             ])
  133.             ->add('captcha'Recaptcha3Type::class, [
  134.                 'constraints' => new Recaptcha3(['message' => 'There were problems with your captcha. Please try again or contact with support and provide following code(s): {{ errorCodes }}']),
  135.                 'action_name' => 'warranty',
  136.                 'locale' => $this->requestStack->getCurrentRequest()->getLocale(),
  137.             ]) 
  138.         ;
  139.     }
  140.     public function configureOptions(OptionsResolver $resolver)
  141.     {
  142.         $resolver->setDefaults([
  143.             'data_class' => Warranty::class,
  144.         ]);
  145.     }
  146. }