<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class MfLicenseType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('valid', ChoiceType::class, [
'label' => false,
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'choices' => [
'Ja' => true,
'Nein' => false,
],
])
->add('category', TextType::class, [
'label' => "Kategorie",
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'attr' => [
'placeholder' => 'Kategorie',
],
])
->add('date', DateType::class, [
'label' => "Datum der Prüfung",
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'years' => range(date('Y'), date('Y')-100),
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
]);
}
}