-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
DateType form field single_text transformer issue #18267
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
Comments
What Symfony version do you use? I have just tried on the latest 2.3 with ICU data 55.1 (also bundled with Symfony now) and all your date examples work just fine. Below the script I used. <?php
require_once __DIR__.'/vendor/autoload.php';
$formFactory = \Symfony\Component\Form\Forms::createFormFactoryBuilder()
->getFormFactory();
foreach (['1985-04-01', '1985-04-02', '1985-04-03'] as $date) {
$form = $formFactory->createBuilder('form')
->add('date_of_birth', 'date', ['widget' => 'single_text', 'format' => 'yyyy-MM-dd'])
->add('submit', 'submit')
->getForm();
$form->submit(['date_of_birth' => $date]);
if ($form->isValid()) {
var_dump($form->getData());
}
} |
The other question is also which timezone he has set. |
We still use 2.6, I know it's no longer maintained, but it's not straightforward for us to upgrade it to 2.7 at the moment. The timezone we use in production is |
@jakzal Thanks for the reference to that ticket. I found out that 1985-04-01 was not a valid time in our production timezone. http://www.timeanddate.com/worldclock/converted.html?iso=19850401T00&p1=27&p2=136 That'd explain why the same code works on my local, but not production, with 765D the same version of INTL extension. |
Hi guys,
When I use "single_text" to render a doctrine
date
field as an HTML5 input field, I get errors when the date is set to "1985-04-01", however, if the value is "1985-04-02" or "1985-04-03", it works. This problem only occurs on our production server, it's not any issue in our local development environment.Code:
I'm able to track down the issue that the error on production server is the result of
TransformationFailedException
. When Symfony transforms string to a datetime object, it gets anIntlDateFormatter
object to parse the string value, should an error occur, it would be recorded and thrown through above Exception class. Symfony instantiates the php built-inIntlDateFormatter
class which is from the INTL extension I believe, I compared the extension on our production server and development server, the version are the same, both 1.1.0, all directives are the same, only difference beingICU version
, which on production is52.1
while in development environment is4.6
.The error I am getting on production for specific dates is
U_PARSE_ERROR
, which indicates something is wrong in theparse
method I mentioned above.I do find Symfony provides an alternative formatter,
Symfony\Component\Intl\DateFormatter\IntlDateFormatter
, but I don't know where it's been used. Is this class intended to tackle issues like I reported?Any help would be appreciated!
Cheers
The text was updated successfully, but these errors were encountered: