8000 [Form] add back model_timezone and view_timezone options by xabbuh · Pull Request #13241 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] add back model_timezone and view_timezone options #13241

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
Jan 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Symfony/Component/Form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
CHANGELOG
=========

2.6.2
-----

* Added back the `model_timezone` and `view_timezone` options for `TimeType`, `DateType`
and `BirthdayType`

2.6.0
-----

* added "html5" option to Date, Time and DateTimeFormType to be able to
enable/disable HTML5 input date when widget option is "single_text"
* added "label_format" option with possible placeholders "%name%" and "%id%"
* [BC BREAK] drop support for model_timezone and view_timezone options in TimeType, DateType and BirthdayType
* [BC BREAK] drop support for model_timezone and view_timezone options in TimeType, DateType and BirthdayType,
update to 2.6.2 to get back support for these options

2.5.0
------
10000 Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'input' => 'datetime',
'with_minutes' => true,
'with_seconds' => false,
'model_timezone' => null,
'view_timezone' => null,
'empty_value' => $emptyValue, // deprecated
'placeholder' => $placeholder,
'html5' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function testInvalidInputOption()
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
Expand All @@ -74,6 +76,8 @@ public function testSubmitFromSingleTextDateTime()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
Expand All @@ -88,6 +92,8 @@ public function testSubmitFromSingleTextString()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'string',
));
Expand All @@ -102,6 +108,8 @@ public function testSubmitFromSingleTextTimestamp()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'timestamp',
));
Expand All @@ -118,6 +126,8 @@ public function testSubmitFromSingleTextRaw()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'array',
));
Expand All @@ -137,6 +147,8 @@ public function testSubmitFromSingleTextRaw()
public function testSubmitFromText()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'text',
));

Expand All @@ -157,6 +169,8 @@ public function testSubmitFromText()
public function testSubmitFromChoice()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -177,6 +191,8 @@ public function testSubmitFromChoice()
public function testSubmitFromChoiceEmpty()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
'required' => false,
));
Expand All @@ -196,6 +212,8 @@ public function testSubmitFromChoiceEmpty()
public function testSubmitFromInputDateTimeDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'datetime',
Expand All @@ -210,6 +228,8 @@ public function testSubmitFromInputDateTimeDifferentPattern()
public function testSubmitFromInputStringDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'string',
Expand All @@ -224,6 +244,8 @@ public function testSubmitFromInputStringDifferentPattern()
public function testSubmitFromInputTimestampDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'timestamp',
Expand All @@ -240,6 +262,8 @@ public function testSubmitFromInputTimestampDifferentPattern()
public function testSubmitFromInputRawDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'array',
Expand Down Expand Up @@ -358,10 +382,25 @@ public function testThrowExceptionIfDaysIsInvalid()

public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
{
date_default_timezone_set('Pacific/Tahiti');
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'America/New_York',
'view_timezone' => 'Pacific/Tahiti',
'input' => 'string',
'widget' => 'single_text',
));

$form->setData('2010-06-02');

$this->assertEquals('01.06.2010', $form->getViewData());
Copy link
Contributor

Choose a reason for hiding this comment

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

This particular test shows the two problematic options are pointless and might be misleading in case of Date/Birthday/Time types. It doesn't matter in which timezone a person was born, changing a timezone shouldn't change a date of birth.

Copy link
Contributor

Choose a reason for hiding this comment

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

That said it's hard to believe that anyone using these types has relied on date being shifted in certain scenarios. I'd rather treat it as a bug.

I think it's fine to bring the options back and ignore them. We shouldn't suggest in the readme they're supported though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would you then suggest to remove these tests and the entry I made to the changelog here?

}

public function testSetDataWithDifferentTimezonesDateTime()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'America/New_York',
'view_timezone' => 'Pacific/Tahiti',
'input' => 'datetime',
'widget' => 'single_text',
));
Expand All @@ -371,7 +410,7 @@ public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
$form->setData($dateTime);

$this->assertDateTimeEquals($dateTime, $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
$this->assertEquals('01.06.2010', $form->getViewData());
}

public function testSetDataWithDifferentPositiveUTCTimezoneDateTime()
Expand Down Expand Up @@ -520,6 +559,8 @@ public function testIsPartiallyFilledReturnsFalseIfSingleText()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
));

Expand All @@ -533,6 +574,8 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -550,6 +593,8 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -567,6 +612,8 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand Down
Loading
0