<?php

namespace App\Form;

use App\Entity\Trend;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\RangeType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Range;

class TrendType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, [
                'label' => 'basics.name'
            ])
            ->add('lowerBound', RangeType::class, [
                'label' => 'basics.lowerBound',
                'attr' => [
                    'min' => 0,
                    'max' => 100,
                    'data-orientation' => "vertical",
                ]
            ])
            ->add('upperBound', RangeType::class, [
                'label' => 'basics.upperBound',
                'attr' => [
                    'min' => 0,
                    'max' => 100
                ]
            
            ])
            ->add('flag', ChoiceType::class, [
                'label' => 'basics.color',
                'choices' => [
                    'Décroissant'      => 'descending',
                    'Stagnant'          => 'stagnant',
                    'Amélioration modérée'    => 'improvement',
                    'Sur la bonne voie'      => 'right',
                    "Maintien de l’atteinte de la cible"     => 'maintaining',
                ],
                'placeholder' => '',
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => Trend::class
        ));
    }
}
