Skip to content

[Form] DateTimeType doesn't render date_label and time_label #61013

@leevigraham

Description

@leevigraham

Question: Is it considered a bug if the docs describe behaviour but the default form theme does not implement the behaviour?

Symfony version(s) affected

7.3 (and all versions back to 4.1)

Description

Originally raised in the docs repo: symfony/symfony-docs#21147

The DateTimeType docs describe config options for date_label and time_label.

These values are set in buildForm method and passed to the child forms.

However these values are never displayed in the bootstrap_base_layout.html.twig theme. This is due to the fact that the form theme renders the child form widget directly.

Looking back in the repo history has always been the case:

Image

How to reproduce

Reproduction Repo: https://github.com/leevigraham/symfony-datetime

Possible Solution(s)

Render the child date and time widget with form_row(). This would render the errors and labels… or include {{ form_label() }} explicitly (see additional context below)

Additional Context

Config was originally added here: #21002 but without an update to the form form_div_layout.html.twig. I guess it was assumed this would be added in user land themes.

However…

The bootstrap_base_layout.html.twig does include labels for the datetime_widget in a sr-only class. It also includes labels for date_widget and time_widget although the implementations seem inconsistent.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy