<commit_before>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    class:     ('form-control ' ~ field.class)|trim,
    label:     field.label,
    multiple:  (field.multiple is defined and field.multiple),
    values:    field.values|default([]),
    info:      field.info|default('')
} %}

{#=== INIT ===========================================================================================================#}

{% if option.values is iterable %}
    {% set values = option.values %}
{% else %}
    {% set lookuptype = option.values|split('/')|first %}
    {% set lookupfield = option.values|split('/')|last %}
    {% if ',' in lookupfield %}
        {% set lookupfield = lookupfield|split(',') %}
    {% endif %}
    {% set sortingorder = field.sort|default(lookupfield|first) %}
    {% set querylimit = field.limit|default(500) %}
    {% set wherefilter = field.filter|default({}) %}
    {% setcontent lookups = lookuptype where wherefilter order sortingorder nohydrate limit querylimit %}
    {% set values = lookups|selectfield(lookupfield, option.multiple, field.keys|default('id')) %}
{% endif %}

{# get the current selection. Either a single value, or an array. #}
{% set selection = context.content.get(contentkey)|default(null) %}
{% if selection is not iterable %}
    {% set selection = [ selection ] %}
{% endif %}

{# If the current selection contains an existing id, we must use _only_ the id, and not accept a fallback. #}
{% if selection|first in values|keys %}
    {% set onlyids = true %}
{% else %}
    {% set onlyids = false %}
{% endif %}

{# If the field has autocomplete, we need to set our own style, and remove the class attribute. #}
{% set attributes = {
    select: {
        class:     field.autocomplete|default(false) ? '' : option.class,
        id:        key,
        multiple:  option.multiple,
        name:      (option.multiple) ? name ~ '[]' : name,
        style:     field.autocomplete|default(false) ? 'width: 100%;' : '',
    }
} %}

{#=== FIELDSET =======================================================================================================#}

{% extends '_base/_fieldset.twig' %}

{% block fieldset_type 'select' %}

{% block fieldset_label_text  labelkey %}<commit_msg>Add fieldset conf to select field<commit_after>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    class:     ('form-control ' ~ field.class)|trim,
    label:     field.label,
    multiple:  (field.multiple is defined and field.multiple),
    values:    field.values|default([]),
    info:      field.info|default('')
} %}

{#=== INIT ===========================================================================================================#}

{% if option.values is iterable %}
    {% set values = option.values %}
{% else %}
    {% set lookuptype = option.values|split('/')|first %}
    {% set lookupfield = option.values|split('/')|last %}
    {% if ',' in lookupfield %}
        {% set lookupfield = lookupfield|split(',') %}
    {% endif %}
    {% set sortingorder = field.sort|default(lookupfield|first) %}
    {% set querylimit = field.limit|default(500) %}
    {% set wherefilter = field.filter|default({}) %}
    {% setcontent lookups = lookuptype where wherefilter order sortingorder nohydrate limit querylimit %}
    {% set values = lookups|selectfield(lookupfield, option.multiple, field.keys|default('id')) %}
{% endif %}

{# get the current selection. Either a single value, or an array. #}
{% set selection = context.content.get(contentkey)|default(null) %}
{% if selection is not iterable %}
    {% set selection = [ selection ] %}
{% endif %}

{# If the current selection contains an existing id, we must use _only_ the id, and not accept a fallback. #}
{% if selection|first in values|keys %}
    {% set onlyids = true %}
{% else %}
    {% set onlyids = false %}
{% endif %}

{# If the field has autocomplete, we need to set our own style, and remove the class attribute. #}
{% set attributes = {
    select: {
        class:     field.autocomplete|default(false) ? '' : option.class,
        id:        key,
        multiple:  option.multiple,
        name:      (option.multiple) ? name ~ '[]' : name,
        style:     field.autocomplete|default(false) ? 'width: 100%;' : '',
    }
} %}

{#=== FIELDSET =======================================================================================================#}

{% extends '_base/_fieldset.twig' %}

{% block fieldset_type 'select' %}

{% set fieldset_conf = {
    autocomplete: field.autocomplete|default(false)
} %}

{% block fieldset_label_text  labelkey %}
{'fraction_non_alphanumeric': 0.2727081138040042, 'fraction_numerical': 0.0025289778714436247, 'mean_word_length': 3.8978328173374615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7650341', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1261, 'n_words': 337}