mirror of
https://github.com/pretix/pretix.git
synced 2026-08-08 10:27:49 +00:00
Correctly apply "required" attribute to address state field
(we try to use it from the country field, which is a <select> tag with default value and therefore never has a "required" attribute - we need to take the information from the .required class of the container)
This commit is contained in:
@@ -5,6 +5,7 @@ $(function () {
|
||||
var dependent = $(this),
|
||||
counter = 0,
|
||||
dependency = $(this).closest(".panel-body, form").find('select[name$=country]'),
|
||||
depRequired = dependency.closest(".form-group").is(".required"),
|
||||
update = function (ev) {
|
||||
counter++;
|
||||
var curCounter = counter;
|
||||
@@ -24,8 +25,8 @@ $(function () {
|
||||
}
|
||||
dependent.append(o);
|
||||
});
|
||||
dependent.closest(".form-group").show();
|
||||
dependent.prop('required', dependency.prop("required"));
|
||||
dependent.closest(".form-group").show().toggleClass('required', depRequired);
|
||||
dependent.prop('required', depRequired);
|
||||
} else {
|
||||
dependent.closest(".form-group").hide();
|
||||
dependent.prop("required", false);
|
||||
@@ -37,7 +38,8 @@ $(function () {
|
||||
if (dependent.find("option").length === 1) {
|
||||
dependent.closest(".form-group").hide();
|
||||
} else {
|
||||
dependent.prop('required', dependency.prop("required"));
|
||||
dependent.closest(".form-group").toggleClass('required', depRequired);
|
||||
dependent.prop('required', depRequired);
|
||||
}
|
||||
dependency.on("change", update);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user