Thanks to visit codestin.com
Credit goes to github.com

Skip to content

symfony/form DateTimeType label=false doesn't work #28198

Closed
@steevanb

Description

@steevanb

Symfony version(s) affected: 3.4 (not tested on 4.x)

Description
DateTimeType doe not take into account label configuration :

  • if defined to false, labels are showned
  • if defined to foo, Year Month Day Hour Minute are showned

Maybe DateType and TimeType have same behavior.

How to reproduce

public function buildForm(FormBuilderInterface $builder, array $options): void
{
    $builder->add(
        'date',
        DateTimeType::class,
        [
            'label' => false,
            'translation_domain' => false
        ]
    );
}

Possible Solution
https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Form/Extension/Core/Type/DateType.php#L111
Fill $yearOptions, $monthOptions and $dayOptions with our label configuration, instead of just required and translation_domain

Additional context
No additional context

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