$(document).on("turbolinks:load", function() {
    $("[data-behavior=update-required-status]").click(function(e) {
        const required = !!($(this)[0] && $(this)[0].checked);


        $("[data-required-tag=guardian]").each(function(index, element) {
            const labelForField = element.previousSibling;

            element.required = required;
            labelForField.classList.add("required");
        });
    });
});