Skip to content

[Form] Add input=date_point to DateTimeType, DateType and TimeType #60315

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

Merged
merged 1 commit into from
May 30, 2025

Conversation

wkania
Copy link
Contributor

@wkania wkania commented May 1, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Based on datetime_immutable.

After DatePointType and DatePointDateType, it would be great to use Forms without needing to transform values into the DatePoint type manually.

use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;

$builder->add('from', DateType::class, [
    'input' => 'date_point',
]);
$builder->add('from', DateTimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', TimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', BirthdayType::class, [
    'input' => 'date_point',
]);

Alternative: Make symfony/clock a hard requirement and refactor the existing DateTimeImmutableToDateTimeTransformer to return a DatePoint instead. This should not introduce any breaking changes.

@wkania wkania requested review from xabbuh and yceruto as code owners May 1, 2025 19:11
@carsonbot carsonbot added this to the 7.3 milestone May 1, 2025
@wkania wkania changed the title [Form] Add to DateTimeType, DateType and TimeType [Form] Add DatePoint to DateTimeType, DateType and TimeType May 1, 2025
@wkania wkania changed the title [Form] Add DatePoint to DateTimeType, DateType and TimeType [Form] Add input=date_point to DateTimeType, DateType and TimeType May 1, 2025
@xabbuh
Copy link
Member

xabbuh commented May 2, 2025

The approach makes sense to me.

@wkania wkania force-pushed the data_point_form branch 2 times, most recently from cb58650 to 521e9cf Compare May 2, 2025 18:06
@wkania wkania requested a review from yceruto May 2, 2025 18:07
@wkania
Copy link
Contributor Author

wkania commented May 2, 2025

I have added DateTimeType and TimeType.

Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@OskarStark OskarStark changed the title [Form] Add input=date_point to DateTimeType, DateType and TimeType [Form] Add input=date_point to DateTimeType, DateType and TimeType May 5, 2025
Copy link
Member

@alexandre-daubois alexandre-daubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Oskar's comment

@ksn135
Copy link

ksn135 commented May 18, 2025

@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
@wkania wkania force-pushed the data_point_form branch from 5074d9d to 4012e83 Compare May 29, 2025 20:10
@wkania
Copy link
Contributor Author

wkania commented May 29, 2025

Updated Changelog 7.3 ->7.4.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to me once this minor comment + @xabbuh's have been addressed

@nicolas-grekas
Copy link
Member

Thank you @wkania.

@nicolas-grekas nicolas-grekas merged commit 21c1205 into symfony:7.4 May 30, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
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