Skip to content

Instantly share code, notes, and snippets.

View gaetanhauray's full-sized avatar

gaetanhauray

View GitHub Profile
/**
* Ajout du champs dans le formulaire, un ChoiceType, multiple, expanded et required
* Image du rendu du champs : https://pasteboard.co/GEGqWpi.png
**/
$constraints = array(
new NotBlank(array('message' => 'mandatory_field'))
);
$form->add(
'fieldValues',
/**
* On affiche une coche pour chaque coregistration
*/
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
/** @var CoregistrationVO $coregistration */
$coregistration = $event->getData();
$form = $event->getForm();
<?php
namespace LB\LBBundle\Form\FormBuilder\Coregistration;
use LB\Common\VO\Coregistration\CoregistrationVO;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;