<?php

namespace App\Form;

use App\Entity\Bibliography;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class BibliographyType extends AbstractType
{
    /**
     * @todo Create status choices from enum
     */
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('status', ChoiceType::class, [
                'choices' => [
                    '-- Select status --' => '',
                    'Draft' => 1,
                    'Complete' => 2,
                    'Unindexed' => 3,
                    'Published' => 4,
                ],
                'label' => 'Status (*)'
            ])
            ->add(
                'editor',
                TextType::class,
                [
                    'label' => 'Editor(s) (*)'
                ]
            )
            ->add('citation', TextType::class, ['label' => 'Citation (*)'])
            ->add('reference', TextareaType::class, ['label' => 'Reference (*)'])
            ->add('notes', TextareaType::class, ['label' => 'Editorial notes', 'required' => false])
        ;
    }

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