-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
DateTimeType HTML5 Chrome #22063
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
Labels
Comments
Well i had to do a bit of work to get it working on chrome, not sure what the current html spec says but the my date time would not use the supplied value unless i used my HTML5_FORMAT {% block date_time_widget %}
{{ form_widget(form, { 'type' : 'datetime-local'}) }}
{% endblock %} /**
* Class UserDateTimeType
* @package AppBundle\Form\Type
*
* Symfony DateTimeType would not render correctly
*/
class UserDateTimeType extends TextType {
/**
* Works in Chrome
*/
const HTML5_FORMAT = 'Y-m-d\Th:i';
/**
* @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage
*/
private $tokenStorage;
/**
* @param TokenStorage $tokenStorage
*/
public function __construct(TokenStorage $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addModelTransformer(new \AppBundle\Form\Transformer\UserDateTimeTransformer($options['model_timezone'], $options['view_timezone'], $options['format']));
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'widget' => 'single_text',
'compound' => false,
'input' => 'sting',
## UserDateTimeTransformer
'format' => self::HTML5_FORMAT,
'model_timezone' => 'UTC',
'view_timezone' => $this->tokenStorage->getToken()->getUser()->getTimeZone(),
]
);
}
/**
* @return null|string
*/
public function getBlockPrefix()
{
return 'date_time';
}
} |
Closed
This looks like the same as #27233 for me which has a pending pull request. So I am going to close here. @ricardosaracino Can you confirm that #28372 fixes your issue too? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: