{# ICON #} {% set icon = field.icon|default(null) %} {% if not icon %} {% if field.type == "text" %} {% if field.subtype is defined %} {% set icon = field.subtype == "email" ? "gogo-icon-mail" : field.subtype == "tel" ? "gogo-icon-phone" : field.subtype == "url" ? "gogo-icon-internet" : "gogo-icon-description" %} {% else %} {% set icon = "gogo-icon-description" %} {% endif %} {% elseif field.type == "number" %} {% set icon = 'gogo-icon-number' %} {% elseif field.type == "email" %} {% set icon = 'gogo-icon-mail' %} {% elseif field.type == "image" %} {% set icon = 'far fa-image' %} {% elseif field.type == "textarea" %} {% set icon = 'gogo-icon-description' %} {% endif %} {% endif %} {# ERROR MESSAGE #} {% set errorMsg = field.errorMsg|default(null) %} {% if not errorMsg %} {% if field.subtype is defined and field.subtype == "email" or field.type == 'email' %} {% set errorMsg = 'commons.errors.bad_email'|trans %} {% elseif field.subtype is defined and field.subtype == "url" or field.type == 'image' %} {% set errorMsg = 'commons.errors.bad_url'|trans %} {% elseif field.type == "number" %} {% set errorMsg = 'commons.errors.bad_number'|trans %} {% elseif field.maxlength is defined %} {% set errorMsg = 'commons.errors.too_long'|trans %} {% endif %} {% endif %} {# CLASS #} {% set inputClass = field.required|default(false) ? "required validate" : "validate"%} {% if field.type == "textarea" and field.subtype == "wysiwyg" %} {% set inputClass = inputClass ~ " ace-editor" %} {% endif %} {# NAME #} {% set baseName = field.type == "title" ? "element" : "data" %} {% set fieldName = field.type == "email" ? 'email' : field.name %} {# TYPE #} {% set inputType = field.subtype is defined ? field.subtype : field.type == "number" ? "number" : "text" %} {% set inputType = field.type == "email" ? 'email' : inputType %} {% set inputType = field.type == "image" ? 'url' : inputType %} {# VALUE #} {% set inputValue = elementValue %} {% if field.type == "title" %}{% set inputValue = element.name %}{% endif %} {% if field.type == "email" %}{% set inputValue = element.email %}{% endif %} {% if not inputValue and field.value is defined %}{% set inputValue = field.value %}{% endif %} {# ICON #} {% if icon %} {% endif %} {# INPUT #} {% if field.type == "textarea" %} {% set inputClass = inputClass ~ " materialize-textarea" %} {% else %} /> {% endif %} {# LABEL #} {% if field.type == "textarea" and field.subtype == "wysiwyg" %} {% endif %}