<?php

namespace App\Dto\Contact;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ContactType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, [
                // Clé de traduction pour le libellé
                'label' => 'contact_form.name.label',
                'attr' => [
                    // Clé de traduction pour le placeholder
                    'placeholder' => 'contact_form.name.placeholder',
                ],
            ])
            ->add('surname', TextType::class, [
                'label' => 'contact_form.surname.label',
                'attr' => [
                    'placeholder' => 'contact_form.surname.placeholder',
                ],
            ])
            ->add('email', EmailType::class, [
                'label' => 'form_email_label',
                'attr' => [
                    'placeholder' => 'contact_form.email.placeholder',
                ],
            ])
            ->add('subject', TextType::class, [
                'label' => 'contact_form.subject.label',
                'attr' => [
                    'placeholder' => 'contact_form.subject.placeholder',
                ],
            ])
            ->add('tel', TextType::class, [
                'label' => 'contact_form.tel.label',
                'required' => false,
                'attr' => [
                    'placeholder' => 'contact_form.tel.placeholder',
                ],
            ])
            ->add('message', TextareaType::class, [
                'label' => 'contact_form.message.label',
                'attr' => [
                    'placeholder' => 'contact_form.message.placeholder',
                    'rows' => 6,
                ],
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefault('data_class', DtoContact::class);
    }
}
