Skip to content

Instantly share code, notes, and snippets.

@gaetanhauray
Created June 6, 2017 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaetanhauray/81f20d3d9e9e8c89f7e19d2985a77365 to your computer and use it in GitHub Desktop.
Save gaetanhauray/81f20d3d9e9e8c89f7e19d2985a77365 to your computer and use it in GitHub Desktop.
{% block checkbox_widget %}
<div class="checkbox_widget">
{% set type = type|default('checkbox') %}
{{ block('form_widget_simple') }}
</div>
{% endblock %}
/**
* 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();
$form->add(
"accepted",
CheckboxType::class,
array(
'label' => $coregistration->getSentence(),
'attr' => array(
'class' => 'field-checkbox',
'logourl' => $coregistration->getLogoUrl()
),
'required' => false,
)
);
}
);
{% form_theme form 'form/coregistration.html.twig' %}
{{ form_widget(formElement) }}
{# Ici formElement correspond à une checkbox #}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment