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] Add input_format option to DateType and DateTimeType #29887

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@fancyweb
Copy link
Contributor

fancyweb commented Jan 14, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29883
License MIT
Doc PR symfony/symfony-docs#10882

Add a new option to specify the date format when using the string input type.

@@ -251,6 +251,7 @@ public function configureOptions(OptionsResolver $resolver)
'empty_data' => function (Options $options) {
return $options['compound'] ? array() : '';
},
'input_format' => 'Y-m-d H:i:s',

This comment has been minimized.

@fancyweb

fancyweb Jan 14, 2019

Author Contributor

Should we set the default here or rely on the transformer default ? IMHO, it's better here so the form type and the transformer are more decoupled.

@@ -292,6 +293,8 @@ public function configureOptions(OptionsResolver $resolver)
'text',
'choice',
));
$resolver->setAllowedTypes('input_format', 'string');

This comment has been minimized.

@fancyweb

fancyweb Jan 14, 2019

Author Contributor

Should we validate the passed input_format ?

@fancyweb fancyweb force-pushed the fancyweb:add-input-format-option-to-date-time-form-types branch from a7303a6 to 12c80e8 Jan 14, 2019

@fancyweb fancyweb force-pushed the fancyweb:add-input-format-option-to-date-time-form-types branch 2 times, most recently from 164ec2e to b4b1296 Jan 17, 2019

@nicolas-grekas nicolas-grekas added this to the next milestone Jan 24, 2019

@nicolas-grekas nicolas-grekas requested a review from xabbuh Jan 24, 2019

@fancyweb fancyweb force-pushed the fancyweb:add-input-format-option-to-date-time-form-types branch from b4b1296 to 869bbde Jan 25, 2019

@xabbuh

xabbuh approved these changes Feb 2, 2019

@xabbuh

This comment has been minimized.

Copy link
Member

xabbuh commented Feb 2, 2019

@fancyweb Can you rebase here?

@fancyweb fancyweb force-pushed the fancyweb:add-input-format-option-to-date-time-form-types branch from 869bbde to 7de0120 Feb 2, 2019

@@ -317,6 +318,8 @@ public function configureOptions(OptionsResolver $resolver)
return '';
});
$resolver->setAllowedTypes('input_format', 'string');

This comment has been minimized.

@yceruto

yceruto Feb 7, 2019

Contributor

return sprintf('Using the "date_format" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class);
//throw new LogicException(sprintf('Cannot use the "date_format" option of the %s when the "widget" option is set to "single_text".', self::class));

As we are going to do with the time_widget option, I wonder if we should throw an exception when the input_format is passed and the value of input is not strictly equal to string'.

@xabbuh

This comment has been minimized.

Copy link
Member

xabbuh commented Feb 15, 2019

@fancyweb Can you rebase here?

@fancyweb fancyweb force-pushed the fancyweb:add-input-format-option-to-date-time-form-types branch from 7de0120 to ef26ad0 Feb 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment