<?php

namespace HVCSiteBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints\Length;

class FraisforfaitType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('libelle','text', array(
                'label'=>'Nom Frais forfait',
                'constraints' => array(
                    new Length(array('min' => 3)),
                ),
                'attr'=>array(
                    'placeholder'=>'Votre nom',
                    'class'=>'',
                    )
                ))

            ->add('montant','money')

            ->add('TypeFrais', 'entity', array(
                'label'=>'Type Frais',
                'class' => 'HVCSiteBundle:Fraisforfait',
                'choice_label' => 'libelle',
                'mapped'=> false, //
            ))

            ->add('ajouter','submit')
        ;
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'HVCSiteBundle\Entity\Fraisforfait'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'hvcsitebundle_fraisforfait';
    }
}
