flowbite-bundle icon indicating copy to clipboard operation
flowbite-bundle copied to clipboard

Date format - incorrect styling with Tailwind / Flowbite styles

Open xVinniVx opened this issue 1 year ago • 1 comments

When I set the date format, to something other than MMddyyyy the select fields change place and it doesn't look good.

How can I deal with this?

Below is a screenshot when the DateType format is: “ddMMyyyy”

image

xVinniVx avatar Aug 15 '24 11:08 xVinniVx

Hello @xVinniVx

Currently the theme only support displaying the DateType in US format

Until I fixed this, the workaround is to either set the DateType widget option to single_text or override the date_widget block in a custom form theme:

# templates/form/layout.html.twig

{% use '@TalesFromADevFlowbite/form/default.html.twig' %}

{%- block date_widget -%}
    {%- if widget == 'single_text' -%}
        {{ block('form_widget_simple') }}
    {%- else -%}
        {%- set attr = attr|merge({'class': attr.class|default('flex')|trim}) -%}
        {%- set attr_class_error = '' -%}
        {%- if not valid -%}
            {%- set attr_class_error = ' ' ~ block('class_input_error') -%}
        {%- endif -%}
        <div {{ block('widget_container_attributes') }}>
            {{- date_pattern|replace({
                '{{ day }}': form_widget(form.month, { attr: { class: (block('class_widget_addon_prepend') ~ ' ' ~ attr_class_error|trim|tailwind_merge) }}),
                '{{ month }}': form_widget(form.day, { attr: { class: ('rounded-none' ~ attr_class_error)|trim|tailwind_merge }}),
                '{{ year }}': form_widget(form.year, { attr: { class: (block('class_widget_addon_append') ~ ' ' ~ attr_class_error|trim|tailwind_merge) }}),
            })|raw -}}
        </div>
    {%- endif -%}
{%- endblock date_widget -%}

ker0x avatar Aug 16 '24 08:08 ker0x

Hello @xVinniVx

This should be fixed in v0.9.1 without any template modification needed!

ker0x avatar Nov 26 '25 09:11 ker0x