field.html.twig 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {% set originalValue = originalValue is defined ? originalValue : value %}
  2. {% set value = (value is null ? field.default : value) %}
  3. {# {% set vertical = field.style == 'vertical' %} #}
  4. {% set vertical = true %}
  5. {% block field %}
  6. <div class="form-field {% if vertical %} vertical{% endif %}">
  7. {% block contents %}
  8. <div class="form-label{% if not vertical %} block size-1-3{% endif %}">
  9. <label class="inline">
  10. {% block label %}
  11. {% if field.help %}
  12. <span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
  13. {% else %}
  14. {{ field.label }}
  15. {% endif %}
  16. {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
  17. {% endblock %}
  18. </label>
  19. </div>
  20. <div class="form-data{% if not vertical %} block size-2-3{% endif %}"
  21. {% block global_attributes %}
  22. data-grav-field="{{ field.type }}"
  23. data-grav-disabled="{{ originalValue is null ? 'true' : 'false' }}"
  24. data-grav-default="{{ field.default|json_encode()|e('html_attr') }}"
  25. {% endblock %}
  26. >
  27. {% block group %}
  28. {% block input %}
  29. <div class="form-input-wrapper {{ field.size }}">
  30. <input
  31. {# required attribute structures #}
  32. name="{{ (scope ~ field.name)|fieldName }}"
  33. value="{{ value|join(', ') }}"
  34. {# input attribute structures #}
  35. {% block input_attributes %}
  36. {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
  37. {% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
  38. {% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
  39. {% if field.disabled %}disabled="disabled"{% endif %}
  40. {% if field.placeholder %}placeholder="{{ field.placeholder }}"{% endif %}
  41. {% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
  42. {% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
  43. {% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
  44. {% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
  45. {% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
  46. {% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
  47. {% if field.validate.message %}title="{{ field.validate.message|e|tu }}"
  48. {% elseif field.title is defined %}title="{{ field.title|e|tu }}" {% endif %}
  49. {% endblock %}
  50. />
  51. </div>
  52. {% endblock %}
  53. {% endblock %}
  54. </div>
  55. {% endblock %}
  56. </div>
  57. {% endblock %}