ui/twig/common/forms/new.html.twig line 1

Open in your IDE?
  1. {% set form = _args.form|default(null) %}
  2. {% set horizontal = (_args.horizontal is defined and _args.horizontal is same as(false)) ? false : _args.horizontal|default(true) %}
  3. {% set id = _args.id|default(null) %}
  4. {% set htmlId = _args.htmlId|default(id) %}
  5. {% set action = _args.action|default(curpath()) %}
  6. {% set method = _args.method|default('POST') %}
  7. {% set showActions = (_args.showActions is defined and _args.showActions is same as(false)) ? false : _args.showActions|default(true) %}
  8. {% set skipCategories = _args.skipCategories|default(false) %}
  9. {% block formHeader %}{% endblock %}
  10. {% if form is not null %}
  11.     {% set attr = {
  12.         'class': (horizontal) ? 'form-horizontal form-contained' : '',
  13.         'id': htmlId,
  14.         'action': action
  15.     } %}
  16.     {% if _args.novalidate is defined %}
  17.         {% set attr = attr|merge({novalidate: 'novalidate'}) %}
  18.     {% endif %}
  19.     {{ form_start(form, {'attr': attr}) }}
  20.     {% if form.vars.errors|length > 0 %}
  21.         {% for error in form.vars.errors %}
  22.             <div class="form-group">
  23.                 <div class="col-sm-12">
  24.                     <p class="bg-danger">{{ error.message }}</p>
  25.                 </div>
  26.             </div>
  27.         {% endfor %}
  28.     {% endif %}
  29. {% else %}
  30.     <form {% if htmlId is not null %}id="{{ htmlId }}"{% endif %} action="{{ action }}" method="{{ method }}" {% if _args.novalidate is defined %}novalidate="novalidate"{% endif %}>
  31. {% endif %}
  32. {% block fields %}
  33.     {% set categories = [] %}
  34.     {% for field in form.children %}
  35.         {% if field.vars.categoryName is defined %}
  36.             {% set categories = categories|merge([field.vars.categoryName]) %}
  37.         {% endif %}
  38.         {% if not field.children or ('collection' in field.vars.block_prefixes) %}
  39.             {% embed '@ui/common/forms/fields/default.html.twig' with {
  40.                 field: field,
  41.                 horizontal: horizontal,
  42.                 skipCategories: skipCategories
  43.             } only %}{% endembed %}
  44.         {% else %}
  45.             {% for child in field.children %}
  46.                 {% embed '@ui/common/forms/fields/default.html.twig' with {
  47.                     field: child,
  48.                     horizontal: horizontal,
  49.                     skipCategories: skipCategories
  50.                 } only %}{% endembed %}
  51.             {% endfor %}
  52.         {% endif %}
  53.     {% endfor %}
  54. {% endblock %}
  55. {% if form is not null %}
  56.     {{ form_rest(form) }}
  57. {% endif %}
  58. {% if showActions %}
  59.     <div class="form-group form-actions">
  60.         <div class="col-sm-12">
  61.             {% block actions %}{% endblock %}
  62.         </div>
  63.     </div>
  64. {% endif %}
  65. {% if form is not null %}
  66.     {{ form_end(form) }}
  67. {% else %}
  68.     </form>
  69. {% endif %}