diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig index 4cdfe4601..79251f765 100644 --- a/Resources/views/Form/fields.html.twig +++ b/Resources/views/Form/fields.html.twig @@ -49,8 +49,7 @@ {{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }} {% endfor %} - {{ form_widget(form._choices) }} - {{ form_widget(form._other) }} + {{ form_widget(form._other, {'attr': {'class': 'input-text-other-value'} }) }} {% endspaceless %} {% endblock choice_with_other_widget %} diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 541f1665c..f1830d04d 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -157,6 +157,13 @@ init_pikaday('{{ app.request.locale }}'); + $('.input-text-other-value').each(function() { + $(this).change(function() { + checkbox = $(this).parent().find("input[type=checkbox][value=_other]")[0]; + $(checkbox).prop('checked', ($(this).val() !== "")) + }); + }); + $('.select2').select2();