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

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
steevanb opened this issue Aug 14, 2018 · 4 comments
Closed

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

steevanb opened this issue Aug 14, 2018 · 4 comments

Comments

@steevanb
Copy link

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

@xabbuh
Copy link
Member

xabbuh commented Sep 14, 2018

@steevanb Can you create a small example project that allows to reproduce your issue? I was not able to reproduce:

bildschirmfoto 2018-09-14 um 08 46 39

@steevanb
Copy link
Author

Just show generated source code, and you will see label is "hidden" by inputs. Not showned, but written and hidden.

@xabbuh
Copy link
Member

xabbuh commented Sep 14, 2018

Hm indeed, for the Boostrap form theme that's true. But is that really an issue if the labels are not shown anyway?

@xabbuh
Copy link
Member

xabbuh commented Sep 14, 2018

This seems to have been introduced with the base bootstrap form theme file when support for Bootstrap 4 was added.

nicolas-grekas added a commit that referenced this issue Sep 18, 2018
… false (xabbuh)

This PR was merged into the 4.1 branch.

Discussion
----------

[Form][TwigBridge] fix not displaying labels when value is false

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28198
| License       | MIT
| Doc PR        |

Commits
-------

c4a6c9f fix not displaying labels when value is false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants