I'm trying to create a dynamic form that loops through all the form fields and dynamically applies the HTML that matches the field type.

I can't seem to find what to use to output: Placeholder, Max Length, Line Breaks, Initial Rows.

Other values like field.type, field.required, field.handle work fine. But trying field.placeholder or field.settings.placeholder does not work.

{% set fields = tab.getFields() %}

{% for field in fields %}

    {% set required = field.required %}
    {% set field = field.getField() %}

    {% if field.type == "PlainText" %}
        <input type="text" name="fields[{{ field.handle }}]" value="{{ attribute(submittedEntry, field.handle) }}" placeholder="">
    {% endif %}

{% endfor %}

The problem is due you're trying to get a property from the FieldLayoutModel instead of FieldLayoutFieldModel please see the code bellow to fix the error.

{%- set layoutFields = tab.getFields() %}

    {% for layoutField in layoutFields -%}

        {%- set field     = layoutField.getField() -%}
        {{ field.settings.placeholder }}
    {% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.