Part-DB-server/templates/settings/settings.html.twig
Copilot e84bae2807
Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293)
* Initial plan

* Make form column layout configurable with global Twig variables

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Rename form column Twig globals to shorter names: label_col, input_col, offset_col

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Fixed remaining places where offsets where used

* Fixed margin of delete button on admin forms

* Rename Twig globals: col_label, col_input, offset_label

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Added documentation to our twig class variables

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
2026-03-07 16:14:58 +01:00

66 lines
3.1 KiB
Twig

{% extends "main_card.html.twig" %}
{% macro genId(widget) %}{{ widget.vars.full_name }}{% endmacro %}
{% form_theme form "form/settings_form.html.twig" %}
{% block title %}{% trans %}settings.title{% endtrans %}{% endblock %}
{% block card_title %}<i class="fa-solid fa-gears fa-fw"></i> {% trans %}settings.title{% endtrans %}{% endblock %}
{% block card_content %}
{{ form_start(form) }}
{# Tabs #}
<ul class="nav nav-tabs">
{% for tab_widget in form %}
{# Create a tab for each compound form #}
{% if tab_widget.vars.compound ?? false %}
<li class="nav-item">
<button type="button" class="nav-link {% if loop.first %}active{% endif %}" aria-current="page" data-bs-toggle="tab"
id="settings-{{ _self.genId(tab_widget) }}-tab" data-bs-target="#settings-{{ _self.genId(tab_widget) }}-pane"
>{{ (tab_widget.vars.label ?? tab_widget.vars.name|humanize)|trans }}</button>
</li>
{% endif %}
{% endfor %}
</ul>
{# Panes #}
<div class="tab-content">
{% for tab_widget in form %}
{# Create a tab for each compound form #}
{% if tab_widget.vars.compound ?? false %}
<div class="tab-pane fade pt-2 {% if loop.first %}show active{% endif %}" id="settings-{{ _self.genId(tab_widget) }}-pane">
{{ form_help(tab_widget) }}
{{ form_errors(tab_widget) }}
{% for section_widget in tab_widget %}
{% set settings_object = section_widget.vars.value %}
{% if section_widget.vars.embedded_settings_metadata is defined %} {# Check if we have nested embedded settings or not #}
<fieldset>
<legend class="{{ offset_label }}">
<i class="fa-solid {{ settings_icon(settings_object)|default('fa-sliders') }} fa-fw"></i>
{{ (section_widget.vars.label ?? section_widget.vars.name|humanize)|trans }}
</legend>
<div class="row">
<div class="{{ offset_label }} col mb-3 ps-2">
<b>{{ form_help(section_widget) }}</b>
{{ form_errors(section_widget) }}
</div>
</div>
{{ form_widget(section_widget) }}
</fieldset>
{% if not loop.last %}
<hr class="mx-0 mb-2 mt-2">
{% endif %}
{% else %} {# If not a compound render as normal row #}
{{ form_row(section_widget) }}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endfor %}
</div>
{{ form_end(form) }}
{% endblock %}