<?php

namespace App\Form;

use Override;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class SubjectType extends AbstractType
{
    /**
     * @SuppressWarnings("PHPMD.UnusedFormalParameter")
     */
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder->add('subject', TextType::class, [
            'label' => 'label.subject',
            'attr' => [
                'placeholder' => 'placeholder.subject',
            ],
            'required' => false,
            'constraints' => [
                new NotBlank([
                    'message' => 'error.subject.blank',
                ]),
            ],
        ]);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => \App\Entity\Subject::class,
        ]);
    }

    #[Override]
    public function getBlockPrefix(): string
    {
        return 'app_subject';
    }
}
