diff --git a/Resources/public/js/chill.js b/Resources/public/js/chill.js index 14a7e93c3..6c7bd0913 100644 --- a/Resources/public/js/chill.js +++ b/Resources/public/js/chill.js @@ -100,7 +100,7 @@ var chill = function() { function _generalDisplayAlertWhenLeavingForm(form_id, alert_message, check_unsaved_data) { var form_submitted = false; var unsaved_data = false; - + $(form_id) .submit(function() { form_submitted = true; @@ -121,7 +121,22 @@ var chill = function() { } }); } - + + function checkNullValuesInChoices(choice_name) { + var choices; + console.log(choice_name); + choices = $("input[name='"+choice_name+"']:checked"); + if (choices.size() === 0) { + $.each($("input[name='"+choice_name+"']"), function (i, e) { + if (e.value === "") { + e.checked = true; + } + }); + } + //} + //}); + } + /** * Display an alert message when the user wants to leave a page containing a given * modified form. @@ -164,5 +179,6 @@ var chill = function() { checkOtherValueOnChange: checkOtherValueOnChange, displayAlertWhenLeavingModifiedForm: displayAlertWhenLeavingModifiedForm, displayAlertWhenLeavingUnsubmittedForm: displayAlertWhenLeavingUnsubmittedForm, + checkNullValuesInChoices: checkNullValuesInChoices, }; } (); \ No newline at end of file diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig index a0b7f88b2..14455872d 100644 --- a/Resources/views/Form/fields.html.twig +++ b/Resources/views/Form/fields.html.twig @@ -58,6 +58,7 @@ {% endfor %} + {% endspaceless %} {% endblock choice_widget_expanded %} @@ -81,9 +82,13 @@
{{ form_widget(form._other, {'attr': {'class': 'input-text-other-value'} }) }}
+ {%- endif -%} {% endfor %} + {% endspaceless %} {% endblock choice_with_other_widget %}