{% if name is defined and name %} {{ hiddenInput(name, '') }} {% endif -%} {% set elements = (elements is defined ? elements : []) -%} {% set jsClass = (jsClass is defined and jsClass ? jsClass : 'Craft.BaseElementSelectInput') -%} {% set sources = (sources is defined and sources ? sources : null) -%} {% set criteria = (criteria is defined and criteria ? criteria : null) -%} {% set storageKey = (storageKey is defined and storageKey ? storageKey : null) -%}
{% for element in elements %} {% include "_elements/element" with { context: 'field', size: (viewMode == 'large' ? 'large' : 'small') } %} {% endfor %}
{% if sources %}
{{ tag('button', { type: 'button', text: selectionLabel, class: ['btn', 'add', 'icon', 'dashed'], aria: { label: selectionLabel, describedby: describedBy ?? false, }, }) }}
{% endif %}
{% do view.registerAssetBundle("craft\\web\\assets\\prismjs\\PrismJsAsset") %} {% set jsSettings = { id: id|namespaceInputId, name: name|namespaceInputName, elementType: elementType, sources: sources, criteria: criteria, sourceElementId: sourceElementId, viewMode: viewMode, limit: limit, modalStorageKey: storageKey, fieldId: fieldId, prevalidate: prevalidate ?? false, canUpload: canUpload, defaultFieldLayoutId: defaultFieldLayoutId, modalSettings: { hideSidebar: hideSidebar ?? false, defaultSource: defaultSource ?? null, defaultSourcePath: defaultSourcePath ?? null, preferStoredSource: preferStoredSource ?? false, showSourcePath: showSourcePath ?? true, indexSettings: { showFolders: showFolders ?? true, }, }, describedBy: (describedBy ?? false) ? describedBy|split(' ')|map(id => id|namespaceInputId)|join(' ') : null, allowSelfRelations: allowSelfRelations ?? false, } %} {% js %} new {{ jsClass }}({{ jsSettings|json_encode|raw }}); {% endjs %}