{% import '_includes/forms.twig' as forms %} {% if (name ?? false) and (renderDefaultInput ?? true) %} {{ hiddenInput(name|replace('/\\[\\]$/', ''), '') }} {% endif -%} {% set id = id ?? "componentselect#{random()}" -%} {% set options = options ?? [] %} {% set values = values ?? (value ?? false ? [value] : []) -%} {% set limit = limit ?? null %} {% set showHandles = showHandles ?? false %} {% set showIndicators = showIndicators ?? false %} {% set showDescription = showDescription ?? false %} {% set sortable = (not limit or limit > 1) and (sortable ?? true) %} {% set showActionMenus = showActionMenus ?? true %} {% set hyperlinks = hyperlinks ?? false %} {% set withSearchInput = withSearchInput ?? (options|length > 5) %} {% set createAction = createAction ?? null %} {% set disabled = (disabled ?? false) ? true : false %} {% set registerJs = registerJs ?? true %} {% set jsClass = jsClass ?? 'Craft.ComponentSelectInput' %} {# sort the options by handle, then label #} {% if showHandles %} {% set options = options|sort((a, b) => a is instance of('craft\\base\\Grippable') ? a.getHandle() <=> b is instance of('craft\\base\\Grippable') ? b.getHandle()) %} {% endif %} {% set options = options|sort((a, b) => a.getUiLabel() <=> b.getUiLabel()) %} {% set containerAttributes = { id: id, class: ['componentselect']|merge((class ?? [])|explodeClass), }|merge(containerAttributes ?? [], recursive=true) %} {%- if block('attr') is defined %} {%- set containerAttributes = containerAttributes|merge(('