{% set static = static is defined ? static : false %} {% set element = element is defined ? element : null %} {% set value = (element ? element.getFieldValue(field.handle) : null) %} {% set errors = (element and not static ? element.getErrors(field.handle) : null) %} {% set fieldtype = field.getFieldType() %} {% set instructions = (not static and field.instructions ? field.instructions|t : null) %} {% if fieldtype %} {% if element %} {% do fieldtype.setElement(element) %} {% endif %} {% if not static %} {# Special-case for Matrix-in-SuperTable #} {% if field.type == 'Matrix' %} {% set input = craft.superTable.getMatrixInputHtml(fieldtype, field.handle, value) %} {% else %} {% set input = fieldtype.getInputHtml(field.handle, value) %} {% endif %} {% else %} {% set input = fieldtype.getStaticHtml(value) %} {% endif %} {% else %} {% set input = '

' ~ "The fieldtype class “{class}” could not be found."|t({ class: field.type }) ~ '

' %} {% endif %} {% if instructions or input %} {% include "_includes/forms/field" with { label: field.name|t|e, locale: field.translatable ? (locale is defined ? locale : (element ? element.locale : craft.locale)), required: (not static ? required : false), instructions: instructions|e, id: field.handle, errors: errors, input: input } only %} {% endif %}