{% extends "admin/cms/page/plugin/change_form.html" %} {% load i18n %} {% block after_field_sets %}
data-field-rules
{% translate "Field value format:" %}
{ "trigger_field_name": { "event_name": { "destination_field_value": [ {"destination_filed_name": [action, ...]} ] } } }
{% translate "List of values" %} action:
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 or a space at the beginning (which is removed), the entered expression is searched directly and not the value of the name attribute." %}
agreement[yes]
const data = { send_to: { change: { custom_email: [ {confirmation_method: ["enable", "required", {set: "notarized_letter"}]}, {"agreement[yes]": [{set: true}]}, {"div.message": ["hide"]}, {" label[for=id_custom_email] abbr": ["show"]}, ], email_in_registry: [ {confirmation_method: ["disable", "optional"]}, {"agreement[yes]": [{set: false}]}, {"div.message": ["show"]}, {" label[for=id_custom_email] abbr": ["hide"]}, ] } }, "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 %}
config
confirmation_method
send_to
custom_email
agreement
yes
email_in_registry
{% 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." %}