stack/src/components/base-form/base-form.twig line 1

Open in your IDE?
  1. {%- set class_name = [
  2.   'base-form',
  3.   props.validate ? "--validate" : null,
  4.   props.full_name ? props.full_name : null,
  5.   props.extra_class ? props.extra_class : null
  6. ]|join(' ')|trim -%}
  7. {%- set attrs = [
  8.   'class="' ~ class_name ~ '"',
  9. ] -%}
  10. {%- if props.id is defined %}
  11.   {% set attrs = attrs|merge(['id="' ~ props.id ~ '"']) %}
  12. {%- endif -%}
  13. {%- if props.action is defined %}
  14.   {% set attrs = attrs|merge(['action="' ~ props.action ~ '"']) %}
  15. {%- endif -%}
  16. {%- if props.method is defined %}
  17.   {% set attrs = attrs|merge(['method="' ~ props.method ~ '"']) %}
  18. {%- endif -%}
  19. {%- if props.enctype is defined %}
  20.   {% set attrs = attrs|merge(['enctype="' ~ props.enctype ~ '"']) %}
  21. {%- endif -%}
  22. {%- if props.autocomplete is defined %}
  23.   {%- set attrs = attrs|merge(['autocomplete="' ~ (props.autocomplete ? 'on' : 'off') ~ '"']) -%}
  24. {%- endif -%}
  25. {%- if props.full_name %}
  26.   {% set attrs = attrs|merge(['name=' ~ props.full_name ~ '']) %}
  27. {%- endif -%}
  28. {%- if props.data is defined -%}
  29.   {%- set data_attrs = [] -%}
  30.   {%- for key, attribute in props.data -%}
  31.     {%- set data_attrs = data_attrs|merge(['data-' ~ key ~ '="' ~ attribute ~ '"']) -%}
  32.   {%- endfor -%}
  33.   {%- set data_attrs = data_attrs|join(' ')|trim -%}
  34.   {%- set attrs = attrs|merge([data_attrs]) -%}
  35. {%- endif -%}
  36. {%- set attrs = attrs|join(' ')|trim -%}
  37. <form {{ attrs|raw }}>
  38.   {% block content %}{# content #}{% endblock %}
  39.   {% if props._token %}
  40.     {% include "@Components/fields/hidden-field/hidden-field.twig" with {props: props._token.vars} %}
  41.   {% endif %}
  42.   {% if props.honung %}
  43.     <div class="d-none">
  44.       {% include "@Components/fields/text-field/text-field.twig" with {props: props.honung.vars|merge({
  45.         type: "email",
  46.       })} %}
  47.     </div>
  48.   {% endif %}
  49. </form>