{# # Form Field Component (Bootstrap 5) # # Reusable form field wrapper with label, input, and validation. # Renders different input types based on the field configuration. # # Expected context: # field_key - Field name/key # field - Field configuration array with: # .type - Input type (text, email, password, tel, select, textarea, checkbox, radio) # .label - Field label # .required - Whether field is required (boolean) # .placeholder - Placeholder text (optional) # .options - Array of options for select/radio (optional) # .value - Current value (optional) # .description - Help text (optional) # .class - Additional CSS classes (optional) # # Usage: # {% include 'components/form-field.html.twig' with { # field_key: 'billing_email', # field: { type: 'email', label: 'Email', required: true } # } %} # # @package WcBootstrap # @since 0.1.0 #} {% set field_type = field.type|default('text') %} {% set field_id = field_key|replace({'_': '-', '[': '-', ']': ''}) %} {% set is_required = field.required|default(false) %} {% if field_type == 'checkbox' %}
{% elseif field_type == 'textarea' %}
{% if field.description is defined and field.description %}
{{ field.description }}
{% endif %}
{% elseif field_type == 'select' %}
{% if field.description is defined and field.description %}
{{ field.description }}
{% endif %}
{% else %}
{% if field.description is defined and field.description %}
{{ field.description }}
{% endif %}
{% endif %}