{% set form = _args.form|default(null) %}
{% set horizontal = (_args.horizontal is defined and _args.horizontal is same as(false)) ? false : _args.horizontal|default(true) %}
{% set id = _args.id|default(null) %}
{% set htmlId = _args.htmlId|default(id) %}
{% set action = _args.action|default(curpath()) %}
{% set method = _args.method|default('POST') %}
{% set showActions = (_args.showActions is defined and _args.showActions is same as(false)) ? false : _args.showActions|default(true) %}
{% set skipCategories = _args.skipCategories|default(false) %}
{% block formHeader %}{% endblock %}
{% if form is not null %}
{% set attr = {
'class': (horizontal) ? 'form-horizontal form-contained' : '',
'id': htmlId,
'action': action
} %}
{% if _args.novalidate is defined %}
{% set attr = attr|merge({novalidate: 'novalidate'}) %}
{% endif %}
{{ form_start(form, {'attr': attr}) }}
{% if form.vars.errors|length > 0 %}
{% for error in form.vars.errors %}
<div class="form-group">
<div class="col-sm-12">
<p class="bg-danger">{{ error.message }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{% else %}
<form {% if htmlId is not null %}id="{{ htmlId }}"{% endif %} action="{{ action }}" method="{{ method }}" {% if _args.novalidate is defined %}novalidate="novalidate"{% endif %}>
{% endif %}
{% block fields %}
{% set categories = [] %}
{% for field in form.children %}
{% if field.vars.categoryName is defined %}
{% set categories = categories|merge([field.vars.categoryName]) %}
{% endif %}
{% if not field.children or ('collection' in field.vars.block_prefixes) %}
{% embed '@ui/common/forms/fields/default.html.twig' with {
field: field,
horizontal: horizontal,
skipCategories: skipCategories
} only %}{% endembed %}
{% else %}
{% for child in field.children %}
{% embed '@ui/common/forms/fields/default.html.twig' with {
field: child,
horizontal: horizontal,
skipCategories: skipCategories
} only %}{% endembed %}
{% endfor %}
{% endif %}
{% endfor %}
{% endblock %}
{% if form is not null %}
{{ form_rest(form) }}
{% endif %}
{% if showActions %}
<div class="form-group form-actions">
<div class="col-sm-12">
{% block actions %}{% endblock %}
</div>
</div>
{% endif %}
{% if form is not null %}
{{ form_end(form) }}
{% else %}
</form>
{% endif %}