CommandeType.php 1.27 KB
Newer Older
1 2 3 4 5 6
<?php

namespace PotageBundle\Form\Membre;

use PotageBundle\Entity\Commande;
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
8 9 10 11 12 13 14 15 16 17
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CommandeType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('prixTotal')
18 19 20 21
            ->add('commandeLegumes', CollectionType::class, array(
                'entry_type' => CommandeLegumesType::class,
                'entry_options' => array('label' => false),
            ))
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
            ->add('sauver', SubmitType::class, array(
                'label' => 'Enregistrer',
                'attr' => array('class' => 'btn btn-dark mb-2')
            ))
        ;
    }
    
    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefault('data_class', Commande::class);
        $resolver->setDefault('attr', array(
            'class' => 'formulaire formulaire_commande',
        ));
    }
    
    public function getBlockPrefix()
    {
        return 'commande';
    }
}