<?php

namespace App\Form;

use App\Entity\User;
use App\Entity\Zprava;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ZpravaType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            -> add('text',TextareaType::class, ['label' => 'Obsah Zprávy', 'required' => false])
            -> add('predmet', TextType::class, ['label' => 'Předmět', 'required' => false])
            -> add('prijemce', EntityType::class, ['class' => User::class, 'label' => 'Příjemce', 'required' => true])
            -> add('save', SubmitType::class,['label' => 'Odeslat', 'attr' => ['class' => 'btn btn-outline-success float-left', 'rows' => '6', 'style' => 'min-width:600px']])
        ;
    }

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