57 lines
2.3 KiB
Twig
57 lines
2.3 KiB
Twig
{% macro form(form_data, formaction, title = "", hiddenid = "", nosubmit = false, idprefix = "") %}
|
|
|
|
{% import "Froxlor/form/formfields.html.twig" as formfields %}
|
|
|
|
<form action="{{ formaction|default("") }}" {% if form_data.id is defined %}id="{{ form_data.id }}"{% endif %} method="post" enctype="multipart/form-data" class="form">
|
|
{% for sid,section in form_data.sections %}
|
|
{% if section.visible is not defined or (section.visible is defined and section.visible == true) %}
|
|
<div class="card mb-3" id="{{ idprefix }}{{ sid }}">
|
|
{% if section.title is not empty %}
|
|
<div class="card-header">
|
|
{% if section.image is not empty %}
|
|
<i class="{{ section.image }}"></i>
|
|
{% endif %}
|
|
{{ section.title }}
|
|
</div>
|
|
{% endif %}
|
|
<div class="formfields">
|
|
{% for id,field in section.fields %}
|
|
{{ formfields.fieldrow(id, field) }}
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if nosubmit == false %}
|
|
<!-- submit buttons -->
|
|
<div>
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
|
|
{% if hiddenid is not empty %}
|
|
<input type="hidden" name="id" value="{{ hiddenid }}"/>
|
|
{% endif %}
|
|
<input type="hidden" name="page" value="{{ page }}"/>
|
|
<input type="hidden" name="action" value="{{ action }}"/>
|
|
<input type="hidden" name="send" value="send"/>
|
|
|
|
<div class="col-12 text-center mb-2 d-grid gap-2 d-md-block">
|
|
{% if form_data.buttons is defined and form_data.buttons is iterable %}
|
|
{% for btn in form_data.buttons %}
|
|
<button type="{{ btn.type|default("submit") }}" class="btn btn-lg {{ btn.class|default(" btn-primary") }}">{{ btn.label }}</button>
|
|
{% endfor %}
|
|
{% else %}
|
|
<button type="reset" class="btn btn-lg btn-outline-secondary me-md-3">{{ lng('panel.reset') }}</button>
|
|
<button type="submit" class="btn btn-lg btn-primary">{{ lng('panel.save') }}</button>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
<span class="text-danger">*</span> {{ lng('panel.mandatoryfield') }}
|
|
</form>
|
|
|
|
{# add translation for custom validations #}
|
|
{% if form_data.id is defined and form_data.id in ['customer_add', 'customer_edit', 'domain_add', 'domain_edit'] %}
|
|
<script>$(function() { $.extend($.validator.messages, {required: "{{ lng('error.requiredfield') }}"}) });</script>
|
|
{% endif %}
|
|
{% endmacro %}
|