<?php
namespace App\Form\Front;
use App\Entity\JobApplication;
use App\Form\Cms\MediaType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Validator\Constraints\File;
class JobApplicationType extends AbstractType
{
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', TextType::class, array('label' => 'label.firstname'))
->add('lastname', TextType::class, array('label' => 'label.lastname'))
->add('email', EmailType::class, array('label' => 'label.email'))
->add('phone', TextType::class, array('label' => 'label.phone'))
->add('message', TextareaType::class, array('label' => 'label.message'))
->add('cv', FileType::class, array(
'label' => '',
'attr' => [
'placeholder' => 'label.upload_cv',
],
'block_prefix' => 'inline_upload',
'required' => true,
'mapped' => false,
'constraints' => [
new File([
'maxSize' => '8192k',
'mimeTypes' => [
'application/pdf',
'application/x-pdf',
'image/jpeg',
'image/png',
],
'mimeTypesMessage' => 'Please upload a valid file',
])
],
))
->add('motivation', FileType::class, array(
'label' => '',
'attr' => [
'placeholder' => 'label.upload_motivation',
],
'block_prefix' => 'inline_upload',
'required' => true,
'mapped' => false,
'constraints' => [
new File([
'maxSize' => '8192k',
'mimeTypes' => [
'application/pdf',
'application/x-pdf',
'image/jpeg',
'image/png',
],
'mimeTypesMessage' => 'Please upload a valid file',
])
],
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => JobApplication::class,
'translation_domain' => 'front',
'type' => '',
));
}
}