I would like to loop through all the fields of a field layout tab form the current entry.
This is working fine to get the field name and value:
{% for fieldLayoutField in entry.getFieldLayout().getFields() if fieldLayoutField.tabId == 50 %}
{% set field = craft.app.fields.getFieldById(fieldLayoutField.id) %}
Field name: {{ field.name }}
Field value: entry[field.handle]
{% endfor %}
But I need to go a step further, by checking the field type, and then handle something different depending of the type.
Example:
{% if field.type == 'dropdown' %}
<select>
{% for option in field.options %}
<option value="{{ option.value }}">
{{ option.label }}
</option>
{% endfor %}
</select>
{% endif %}
As {{ field.type }}
and {{ entry[field.handle].type }}
aren't defined, I can't guess properly when this is, for example, a Plain Text field or a Dropdown field.
I could guess some fields type, by some checks like bellow, but it sounds very dirty:
field.columnType
returnstext
if a Plain Text field.field.options | length
returnstrue
if a Dropdown field.
For some others, like the Lightswitch field, I don't know exactly how to guess the type properly.