-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Added options for separate date/time labels in DateTimeType. #21002
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
Conversation
@mktcode : Just to mention a pending discussion on the way we'll allow to specify sub-types labels: #20887 (comment) |
Would it make sense to make all options of the subtypes configurable (i.e. add options like |
I just handled it like the widget options ( |
Configuring every sub-types options does not really make sense to me. You shouldn't care about most of them, which are inherited or guessed within the parent type acting as encapsulation. |
What's the status of this PR? |
This PR is coherent with current handling of subtype options, so it seemed viable to me. On the other hand, in case of sub types, granting access to all of their options seems very legit too, but maybe this is a topic of its own. |
+1 for accessibility reasons (http://webaim.org/techniques/forms/controls#input) form rows: Personally I use this SO solution for form row atributes on a regular basis in all of my projects. |
Thinking about this again the proposed solution looks good to me and is in line with the existing @mktcode Can you check the failure and make fabbot happy? |
Thank you @mktcode. |
…DateTimeType. (mktcode) This PR was squashed before being merged into the 4.2-dev branch (closes #21002). Discussion ---------- [Form] Added options for separate date/time labels in DateTimeType. If your render date and time separately you need options for each label. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Let's say you have the following form field: ``` $builder ->add('start', DateTimeType::class, [ 'date_widget' => 'single_text', ... ]) ... ``` Then you can render the date and time widgets/rows/etc. separately: ``` <div>{{ form_row(form.start.date) }}</div> <div>{{ form_row(form.start.time) }}</div> ``` But you can't provide labels for each, so what is displayed is just the uppercased field name ("Date" and "Time"). This PR adds 'date_label' and 'time_label' options, so you can do: ``` $builder ->add('start', DateTimeType::class, [ 'date_widget' => 'single_text', 'date_label' => 'The Start Date', 'time_label' => 'The Start Time', ... ]) ... ``` Commits ------- df19155 [Form] Added options for separate date/time labels in DateTimeType.
@mktcode thanks! We've created symfony/symfony-docs#10292 to not forget about documenting this new feature. If you want to give it a try, we can help you as much as you need in the Symfony Docs repository. Thanks! |
If your render date and time separately you need options for each label.
Let's say you have the following form field:
Then you can render the date and time widgets/rows/etc. separately:
But you can't provide labels for each, so what is displayed is just the uppercased field name ("Date" and "Time").
This PR adds 'date_label' and 'time_label' options, so you can do: