<?php
namespace App\Form;
use App\Entity\Warranty;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
use Symfony\Component\HttpFoundation\RequestStack;
class WarrantyType extends AbstractType
{
private $requestStack;
public function __construct( RequestStack $requestStack )
{
$this->requestStack = $requestStack;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('serialNumber', TextType::class, [
'label' => 'CoaguChek<sup>®</sup> INRange serial #*:',
'label_html' => true,
'label_attr' => ['class' => 'info'],
'help' => 'The serial number is on the back of the meter above the barcode.'
])
->add('dateOfPurchase', DateType::class, [
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'attr' => [
'autocomplete' => 'off'
],
'label' => 'Date of purchase*:'
])
->add('firstname', TextType::class, [
'label' => 'First name*:'
])
->add('lastname', TextType::class, [
'label' => 'Last name*:'
])
->add('dateOfBirth', DateType::class, [
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'attr' => [
'autocomplete' => 'off'
],
'label' => 'Date of birth*:'
])
->add('inrSelfTesting', ChoiceType::class, [
'choices' => [
'Yes' => 'yes',
'No' => 'no'
],
'expanded' => true,
'multiple' => false,
'label' => 'Is this meter for your own use to do INR self-testing?*',
'attr' => ['class' => 'form-check-inline'],
])
->add('purpose', TextType::class, [
'label' => 'If no, how will you use this meter?',
'required' => false
])
->add('healthcareProfessional', ChoiceType::class, [
'choices' => [
'Yes' => 'yes',
'No' => 'no'
],
'attr' => ['class' => 'form-check-inline'],
'expanded' => true,
'multiple' => false,
'label' => 'Are you a healthcare professional?*'
])
->add('profession', TextType::class, [
'label' => 'If yes, please indicate profession',
'required' => false
])
->add('street', TextType::class, [
'label' => 'Street*:'
])
->add('unit', TextType::class, [
'label' => 'Unit:',
'required' => false
])
->add('city', TextType::class, [
'label' => 'City*:'
])
->add('postalCode', TextType::class, [
'label' => 'Postal code*:'
])
->add('phone', TextType::class, [
'label' => 'Phone*:'
])
->add('email', EmailType::class, [
'label' => 'Email*:'
])
->add('language', ChoiceType::class, [
'choices' => [
'English' => 'english',
'French' => 'french'
],
'expanded' => true,
'multiple' => false,
'label' => 'Language*:'
])
->add('declarationPrescription', CheckboxType::class, [
'label' => 'I am aware that a prescription is required for a patient to have INR testing done with the CoaguChek<sup>®</sup> INRange system.',
'label_html' => true,
'required' => false
])
->add('declarationTestLimitation', CheckboxType::class, [
'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).',
'label_html' => true,
'required' => false
])
->add('declarationCorrectly', CheckboxType::class, [
'label' => 'I can use the CoaguChek<sup>®</sup> INRange meter correctly to obtain a coagulation result.',
'label_html' => true,
'required' => false
])
->add('declarationQuestions', CheckboxType::class, [
'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.',
'required' => false
])
->add('declarationCommunications', CheckboxType::class, [
'label' => 'I would like to receive communications from Roche such as CoaguChek<sup>®</sup> product news and promotions',
'label_html' => true,
'required' => false
])
->add('captcha', Recaptcha3Type::class, [
'constraints' => new Recaptcha3(['message' => 'There were problems with your captcha. Please try again or contact with support and provide following code(s): {{ errorCodes }}']),
'action_name' => 'warranty',
'locale' => $this->requestStack->getCurrentRequest()->getLocale(),
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Warranty::class,
]);
}
}