Skip to content
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

[Form] Allow date_widget *and* time_widget to be set to single_text #43129

Closed
ThomasLandauer opened this issue Sep 21, 2021 · 3 comments
Closed

Comments

@ThomasLandauer
Copy link
Contributor

Description
Follow-up of EasyCorp/EasyAdminBundle#4027

I'm suggesting to allow rendering a DateTimeType in two widgets:

  • A single_text for date,
  • and a single_text for time

...by setting both date_widget and time_widget to single_text.

Right now, the documentation is misleading, cause there's no hint that you can't use single_text for both. So if nobody changes the implementation, I'm going to add a hint to the docs ;-)

@javiereguiluz found the relevant code part:

$resolver->setNormalizer('date_format', function (Options $options, $dateFormat) {
if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) {
throw new LogicException(sprintf('Cannot use the "date_format" option of the "%s" with an HTML5 date.', self::class));
}
return $dateFormat;
});
$resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) {
if (null !== $dateWidget && 'single_text' === $options['widget']) {
throw new LogicException(sprintf('Cannot use the "date_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class));
}
return $dateWidget;
});
$resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) {
if (null !== $timeWidget && 'single_text' === $options['widget']) {
throw new LogicException(sprintf('Cannot use the "time_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class));
}
return $timeWidget;
});
$resolver->setNormalizer('html5', function (Options $options, $html5) {
if ($html5 && self::HTML5_FORMAT !== $options['format']) {
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
}
return $html5;
});

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

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

3 participants