{% for fieldId, layoutElement in blockTypeFields[blockTypeId] %}
{% set field = layoutElement.getField() %}
{% set hasName = field.name and field.name != '__blank__' %}
{{ forms.field({
label: "Configuration"|t('app'),
instructions: "Define the types of blocks that can be created within this Matrix field, as well as the fields each block type is made up of."|t('app'),
name: 'config',
errors: matrixField.getErrors('blockTypes'),
}, blockTypeInput) }}
{% if craft.app.getIsMultiSite() %}
{{ forms.selectField({
label: 'Propagation Method'|t('app'),
instructions: 'Which sites should blocks be saved to?'|t('app'),
id: 'propagationMethod',
name: 'propagationMethod',
options: [
{ value: 'none', label: 'Only save blocks to the site they were created in'|t('app') },
{ value: 'siteGroup', label: 'Save blocks to other sites in the same site group'|t('app') },
{ value: 'language', label: 'Save blocks to other sites with the same language'|t('app') },
{ value: 'all', label: 'Save blocks to all sites the owner element is saved in'|t('app') },
{ value: 'custom', label: 'Custom…'|t('app') },
],
value: matrixField.propagationMethod,
toggle: true,
targetPrefix: 'propagation-method-',
}) }}
{% tag 'div' with {
id: 'propagation-method-custom',
class: matrixField.propagationMethod != 'custom' ? 'hidden' : null,
} %}
{{ forms.textField({
label: 'Propagation Key Format'|t('app'),
instructions: 'Template that defines the field’s custom “propagation key” format. Blocks will be saved to all sites that produce the same key.'|t('app'),
id: 'propagation-key-format',
class: 'code',
name: 'propagationKeyFormat',
value: matrixField.propagationKeyFormat,
errors: matrixField.getErrors('propagationKeyFormat'),
}) }}
{% endtag %}
{% if matrixField.id and matrixField.propagationMethod != 'none' %}
{% js %}
(function() {
var showingWarning = false;
$("#{{ 'propagationMethod'|namespaceInputId }}").on('change', function() {
if ($(this).val() !== '{{ matrixField.propagationMethod }}') {
if (!showingWarning) {
$('', {'class': 'warning', text: "{{ 'Applying this change to existing blocks can take some time.'|t('app')|e('js') }}"})
.appendTo($("#{{ 'propagationMethod-field'|namespaceInputId }}"));
showingWarning = true;
}
} else if (showingWarning) {
$("#{{ 'propagationMethod-field'|namespaceInputId }} .warning").remove();
showingWarning = false;
}
});
})();
{% endjs %}
{% endif %}
{% endif %}
{{ forms.textField({
label: "Min Blocks"|t('app'),
instructions: "The minimum number of blocks the field is allowed to have."|t('app'),
id: 'minBlocks',
name: 'minBlocks',
value: matrixField.minBlocks,
size: 3,
errors: matrixField.getErrors('minBlocks')
}) }}
{{ forms.textField({
label: "Max Blocks"|t('app'),
instructions: "The maximum number of blocks the field is allowed to have."|t('app'),
id: 'maxBlocks',
name: 'maxBlocks',
value: matrixField.maxBlocks,
size: 3,
errors: matrixField.getErrors('maxBlocks')
}) }}