Hello, everyone,
I have a form type that I embed in many places in the code. Now I wanted to create an include template for this, so that I can make adjustments at any time - but only in one central place.
The only problem here is the definition of the database fields. So:
{{ entry.database_field }}
Is there a way that my passed string (database_field=“flavor”) selects the correct database field? Similar to the setattr() method.
My template:
{% block content %}
{% include "includes/form-fullscreen-selection.html" with queryset=myqueryset database_field="flavor" %}
{% endblock content %}
My include file:
<div class="fullscreen-form identifier">
<div>
<p>Back</p>
</div>
<form>
<input type="search" placeholder="Search">
</form>
<div>
{% for entry in queryset %}
<div class="fullscreen-form-option">
<div class="flex-row-space-between">
<p>{{ entry.database_field }}</p>
</div>
<div class="flex-row-space-between display-none">
<img class="icon-h18" src="{{ MEDIA_URL }}image/base/icon/icon-checked-green.png">
<p>{{ entry.database_field }}</p>
</div>
</div>
{% endfor %}
</div>
</div>