I have multiple entries fields that I want to use in the front-end. In the field settings I'll set up a sections source for each field. On the frontend I want a dropdown select box with all the entries from section I'll setup for each entries field. If I'll dump the field sources from the field layout I'll get this:
array(1) {
[0]=>
string(44) "section:a0977adf3fd-bd50adf-479cadf-90cd-8d5ef46de79c"
}
How to get entries related to the section source above?
{% entries = craft.entries.section(field.sources).all() %} // This is not working
This is the code where I'll need it for some context
{% for tab in entry.fieldLayout.tabs %}
{{ tab.name }}
{% for field in tab.getFields() %}
<label for="{{ field.handle }}">{{ field.name }}</label>
{% if field.className == 'craft\\fields\\PlainText' %}
{# field text settings #}
{% elseif field.className == 'craft\\fields\\Number' %}
{# field number settings #}
{% elseif field.className == 'craft\\fields\\Entries' %}
{% set entries = craft.entries.section(field.sources).all() %}
{# entries is empty how to fix? #}
<select name="fields[{{ field.handle }}][]">
<option value="">Choose</option>
{% for entry in entries %}
<option value="{{ entry.id }}">{{ entry.title }}</option>
{% endfor %}
</select>
{% endif %}
{% endfor %}
{% endfor %}