<?php

namespace App\Form;

use App\Entity\Project;
use App\Entity\Tag;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ProjectType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', null, [
                'label' => 'field.project.name',
            ])
            ->add('description', null, [
                'label' => 'field.project.description',
            ])
            ->add('hashtags', null, [
                'label' => 'field.project.hashtags',
                'help_html' => true,
                'help' => 'field.project.hashtags_help',
            ])
            ->add('source', null, [
                'label' => 'field.project.source',
                'help_html' => true,
                'help' => 'field.project.source_help',
            ])
            ->add('imagery', null, [
                'label' => 'field.project.imagery',
                'help_html' => true,
                'help' => 'field.project.imagery_help',
            ])
            ->add('overpassQuery', null, [
                'label' => 'field.project.overpass',
                'required' => false,
                'help_html' => true,
                'help' => 'field.project.overpass_help',
            ])
            ->add('tags', EntityType::class, [
                'label' => 'field.project.tags',
                'class' => Tag::class,
                'choice_label' => 'name',
                'multiple' => true,
                'expanded' => true,
            ])
        ;
    }

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