<?php

// src/Form/Type/UserType.php
namespace App\Form\Type;

use App\Document\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UserType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('email', EmailType::class, [
            'label' => 'Email']);
        $builder->add('password', RepeatedType::class, [
           'first_name' => 'password',
           'second_name' => 'confirm',
           'type' => PasswordType::class,
           'first_options' => ['label' => 'Heslo'],
           'second_options' => ['label' => 'Heslo znovu']
        ]);
    }

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