{% import 'macros/form.html' as form %} {% macro help_text() %} {% snippet 'scheming/form_snippets/help_text.html', field=field %} {% endmacro %} {% set selected = h.relationship_get_current_relations_list(field, data) %} {% if not selected %} {% set selected = request.args[field.field_name] %} {% endif %} {% set classes = ['control-full'] %} {% if field.hidden_from_form %} {% do classes.append('hidden') %} {% endif %} {% call form.input_block( 'field-' ~ field.field_name, label=h.scheming_language_text(field.label), classes=classes, error=errors[field.field_name], is_required=h.scheming_field_required(field), extra_html=help_text() ) %} {% set current_entity_id = data.get('id', None) %} {% set entities = h.relationship_get_entity_list(field.related_entity, field.related_entity_type) %} {% set choices = [] %} {% for entity in entities if entity.id != current_entity_id %} {% if not field.get('updatable_only', false) or h.check_access(field.related_entity ~ '_update', {'id': entity.id }) %} {% do choices.append((entity.id, entity.get('title') or entity.get('name'))) %} {% endif %} {% endfor %} {% set choices = choices|sort(case_sensitive=false, attribute=1) %} {% if not h.scheming_field_required(field) and not field.multiple %} {% do choices.insert(0, ('', 'No relation')) %} {% endif %} {% endcall %}