<?php
declare(strict_types=1);
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Contracts\Translation\TranslatorInterface;
class JobApplicationFormType extends AbstractType
{
private $translator;
public function __construct(TranslatorInterface $translator = null)
{
$this->translator = $translator;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class)
->add('email', EmailType::class)
->add('coverLetter', TextareaType::class)
->add('cvFile', FileType::class, [
'mapped' => false,
'constraints' => [
new NotNull(),
new File(
[
'mimeTypes' => [
'application/pdf',
'application/x-pdf',
'application/msword', // doc
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // docx
'application/vnd.openxmlformats-officedocument.wordprocessingml.template', // dotx
'application/vnd.oasis.opendocument.text', // odt
'image/jpeg', // jpeg
'image/jpg', // jpg
'image/png', // png
],
'mimeTypesMessage' => $this->translator->trans('file_uploader.mime_type_error', [], 'validators')
]
)
]
])
->add('privacyPolicyAccepted', CheckboxType::class)
->add('send', SubmitType::class);
}
}