mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-23 10:44:24 +00:00
select radio button with empty value
if multiple radio button doesn't have a value, the default one is checked. This is done using javascript, currently.
This commit is contained in:
parent
06cc78c5cb
commit
9aa686fac6
@ -122,6 +122,21 @@ 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
|
* Display an alert message when the user wants to leave a page containing a given
|
||||||
* modified form.
|
* modified form.
|
||||||
@ -164,5 +179,6 @@ var chill = function() {
|
|||||||
checkOtherValueOnChange: checkOtherValueOnChange,
|
checkOtherValueOnChange: checkOtherValueOnChange,
|
||||||
displayAlertWhenLeavingModifiedForm: displayAlertWhenLeavingModifiedForm,
|
displayAlertWhenLeavingModifiedForm: displayAlertWhenLeavingModifiedForm,
|
||||||
displayAlertWhenLeavingUnsubmittedForm: displayAlertWhenLeavingUnsubmittedForm,
|
displayAlertWhenLeavingUnsubmittedForm: displayAlertWhenLeavingUnsubmittedForm,
|
||||||
|
checkNullValuesInChoices: checkNullValuesInChoices,
|
||||||
};
|
};
|
||||||
} ();
|
} ();
|
@ -58,6 +58,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">chill.checkNullValuesInChoices("{{ form.vars.full_name }}");</script>
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
{% endblock choice_widget_expanded %}
|
{% endblock choice_widget_expanded %}
|
||||||
|
|
||||||
@ -81,9 +82,13 @@
|
|||||||
<div class="grid-6 grid-tablet-12 gid-mobile-12 no-gutter">
|
<div class="grid-6 grid-tablet-12 gid-mobile-12 no-gutter">
|
||||||
{{ form_widget(form._other, {'attr': {'class': 'input-text-other-value'} }) }}
|
{{ form_widget(form._other, {'attr': {'class': 'input-text-other-value'} }) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
chill.checkNullValuesInChoices("{{ form._choices.vars.full_name }}");
|
||||||
|
</script>
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
{% endblock choice_with_other_widget %}
|
{% endblock choice_with_other_widget %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user