<?php

namespace App\Form;

use App\Entity\Task;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TaskType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', null, [
                'label' => 'field.task.name',
            ])
            ->add('description', null, [
                'label' => 'field.task.description',
            ])
            ->add('geojson', TextareaType::class, [
                'label' => 'field.task.geojson',
                'required' => false,
                'help_html' => true,
                'help' => 'field.task.geojson_help',
            ])
            ->add('osm', TextareaType::class, [
                'label' => 'field.task.osm',
                'required' => false,
                'help_html' => true,
                'help' => 'field.task.osm_help',
                'empty_data' => '',
            ])
            ->add('status', TaskLifecycleType::class, [
                'label' => 'field.task.status',
            ])
            ->add('urgent', null, [
                'label' => 'field.task.urgent',
                'required' => false,
                'help' => 'field.task.urgent_help',
            ])
            ->add('important', null, [
                'label' => 'field.task.important',
                'required' => false,
                'help' => 'field.task.important_help',
            ])
        ;
    }

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