templates/Layout/forms/input.html.twig line 1

Open in your IDE?
  1. {% set container_class = container_class ?? null %}
  2. {% set label = label ?? null %}
  3. {% set emptyLabel = emptyLabel ?? false %}
  4. {% set label_attr = label_attr ?? [] %}
  5. {% set widgetContainer = widgetContainer ?? '' %}
  6. {% set type = type ?? 'text' %}
  7. {% set value = value ?? false %}
  8. {% set no_label = no_label ?? false %}
  9. {% set required = required ?? true %}
  10. {% set readOnly = readOnly ?? false %}
  11. {% set error_message = error_message ?? 'Ce champ est obligatoire.' %}
  12. {% set success_message = success_message ?? '' %}
  13. {% set help_message = help_message ?? false %}
  14. {% set prefix = prefix ?? false %}
  15. {% set dataUnit = dataUnit ?? false %}
  16. {# input attribute attributes #}
  17. {% set attr = {
  18.     'class': null,
  19.     'placeholder': null,
  20.     'readonly': readOnly,
  21. }|merge(attr ?? {}) %}
  22. {% set name = name ?? null %}
  23. {% if container_class %}
  24.     <div class="{{ container_class }}">
  25. {% endif %}
  26.     {% if field is defined and field is not null %}
  27.         {% set label = label ?? field.vars.label %}
  28.         {% set attr = attr|merge(field.vars.attr) %}
  29.         {% set label_attr = label_attr|merge(field.vars.label_attr) %}
  30.         {% if label %}
  31.             {{ form_label(field, label, {'label_attr': label_attr}) }}
  32.         {% elseif emptyLabel %}
  33.             <div class="input-label">&nbsp;</div>
  34.         {% endif %}
  35.         <div class="is-relative {{ widgetContainer }}">
  36.             {{ form_widget(field, {'attr': attr}) }}
  37.         {% if attr["data-unite"] is defined %}
  38.                 <div class="input-unit js-class-for-consultation-input">{{attr["data-unite"]}}</div>
  39.         {% endif %}
  40.         </div>
  41.         {% if required %}
  42.             <small class="form-error">{{ error_message }}</small>
  43.         {% endif %}
  44.         {% if help_message %}
  45.             <span class="form-help">{{ help_message }}</span>
  46.         {% endif %}
  47.         {{ form_errors(field) }}
  48.     {% else %}
  49.         {% if label %}
  50.             <label for="{{ id }}" class="{{ label_attr.class }}">{{ label }}</label>
  51.         {% endif %}
  52.         <input
  53.             id="{{ id }}"
  54.             type="{{ type }}"
  55.             class="input {{ attr.class }}"
  56.             name="{{ name }}"
  57.             {% if attr.placeholder %}
  58.                 placeholder="{{ attr.placeholder }}"
  59.             {% endif %}
  60.             {% if attr.pattern ?? false %}
  61.                 pattern="{{ attr.pattern }}"
  62.             {% endif %}
  63.             {% if value %}
  64.                 value="{{ value }}"
  65.             {% endif %}
  66.             {% if required %}
  67.                 required
  68.             {% endif %}
  69.             {# {% if dataUnit %}
  70.                 data-unit = "{{dataUnit}}"
  71.             {% endif %} #}
  72.         >
  73.         {% if required %}
  74.             <small class="form-error">{{ error_message }}</small>
  75.         {% endif %}
  76.         {% if atrr["data-unite"] is defined %}
  77.                 <div>test</div>
  78.         {% endif %}
  79.         {% if help_message %}
  80.             <span class="form-help">{{ help_message }}</span>
  81.         {% endif %}
  82.     {% endif %}
  83. {% if container_class %}
  84.     </div>
  85. {% endif %}