{% for element in craft.app.elements.getAllElementTypes() %}
    {% if element in allowedElements %}
        {% set elementOptions = [] %}

        {% if element == 'craft\\elements\\Entry' %}
            {% for section in craft.app.entries.getAllSections() %}
                {% set elementOptions = [{ value: section.uid, label: section.name | e }] | merge(elementOptions) %}
            {% endfor %}
        {% elseif element == 'craft\\elements\\Category' %}
            {% for group in craft.app.categories.