add javascript to ensure that fields with '_other' are checked - close #349

This commit is contained in:
Marc Ducobu 2014-11-26 17:50:08 +01:00
parent 79ccfb184a
commit ab4d9e174f
2 changed files with 8 additions and 2 deletions

View File

@ -49,8 +49,7 @@
{{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }}
</div>
{% 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 %}

View File

@ -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();
</script>