{% extends "admin/cms/page/plugin/change_form.html" %} {% load i18n %} {% block after_field_sets %}

{% translate "Help for activating Javascript" %}

{% translate "Description of how to set up javascript for form control." %}

{% blocktranslate %}Event settings for form fields are defined in the data-field-rules attribute.{% endblocktranslate %}

{% translate "Field value format:" %}

{
    "trigger_field_name": {
        "event_name": {
            "destination_field_value": [
                {"destination_filed_name": [action, ...]}
            ]
        }
    }
}

{% translate "List of values" %} action:

{% translate "The field name can also include the field value. This is necessary for radio buttons or a group of checkboxes. The field value is given in square brackets." %} {% blocktranslate %}For example, agreement[yes] sets the field <input type="radio" name="agreement" value="yes">.{% endblocktranslate %} {% translate "If there is a dot in the name, the entered expression is searched directly and not the value of the name attribute." %}

{% translate "Example" %}:
const data = {
    send_to: {
        change: {
            custom_email: [
                {confirmation_method: ["enable", "required", {set: "notarized_letter"}]},
                {"agreement[yes]": [{set: true}]},
                {"div.message": ["hide"]},
            ],
            email_in_registry: [
                {confirmation_method: ["disable", "optional"]},
                {"agreement[yes]": [{set: false}]},
                {"div.message": ["show"]},
            ]
        }
    },
    "policy[confirm]": {
        change: {
            true: {"message": [{set: "Thank you."}]},
            false: {"message": [{set: "Please, check the checkbox."}]},
        }
    }
}
const config = JSON.stringify(data)

{% blocktranslate trimmed %} Put the config value in the data-field-rules attribute. This will cause the confirmation_method field to be activated when the send_to field is set to custom_email, making it mandatory and setting its value to "notarized_letter". The agreement checkbox is also checked with a value of yes. The confirmation_method field is deactivated and made optional when the send_to field is set to email_in_registry. The agreement checkbox is cleared with a value of yes. {% endblocktranslate %}

{% translate "The current configuration can be saved in readable form with the command" %}:

JSON.stringify(JSON.parse(document.querySelector("[data-field-rules]").dataset.fieldRules), null, 2)

{% translate "Script debugging can be enabled with the url parameter ?debug=true." %}

{% endblock %}