<?php

namespace App\Form;

use App\Entity\Rodic;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class RodicType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            -> add('jmeno', TextType::class, ['label' => 'Jméno','required' => true, 'attr' => ['placeholder' => 'Jméno']])
            -> add('prijmeni', TextType::class, ['label' => 'Příjmení','required' => true, 'attr' => ['placeholder' => 'Příjmení']])
            -> add('titul', TextType::class, ['label' => 'Tituly', 'required' => false, 'attr' => ['placeholder' => 'Tituly']])
            -> add('datNar', DateType::class, ['years' => range(date('Y') - 18,1900),'label' => 'Země pobytu'])
            -> add('image', FileType::class, ['mapped' => false, 'required' => false, 'attr' => ['placeholder' => 'Vyberte'], 'label' => 'Profilový obrázek'])
            -> add('stat', TextType::class, ['label' => 'Země pobytu', 'required' => true, 'attr' => ['placeholder' => 'Země pobytu']])
            -> add('obec', TextType::class, ['label' => 'Obec', 'required' => true, 'attr' => ['placeholder' => 'Obec']])
            -> add('mCast', TextType::class, ['label' => 'Městská část', 'required' => true, 'attr' => ['placeholder' => 'Městská část']])
            -> add('ulice', TextType::class, ['label' => 'Ulice', 'required' => true, 'attr' => ['placeholder' => 'Ulice']])
            -> add('cisPop', TextType::class, ['label' => 'Číslo popisné', 'required' => true, 'attr' => ['placeholder' => 'Číslo popisné']])
            -> add('psc', TextType::class, ['label' => 'Poštovní směrovací číslo', 'required' => true, 'attr' => ['placeholder' => 'Poštovní směrovací číslo']])
            -> add('email', TextType::class, ['label' => 'E-mail','required' => false, 'attr' => ['placeholder' => 'E-mailová adresa']])
            -> add('telefon', TelType::class, ['attr' => ['data-mask' => '+000000000000', 'placeholder' => 'Telefon'], 'label' => 'Telefon', 'required' => false])
            -> add('save', SubmitType::class,['attr' => ['class' => 'btn btn-outline-success float-left'], 'label' => 'Uložit'])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Rodic::class,
        ]);
    }
}
