[Form] Fixed the default value of "format" in DateType to DateType::DEFAULT_FORMAT if "widget" is not "single_text"
This commit is contained in:
parent
889bd2ee62
commit
6e7e08f8c4
@ -180,6 +180,10 @@ class DateType extends AbstractType
|
||||
);
|
||||
};
|
||||
|
||||
$format = function (Options $options) {
|
||||
return $options['widget'] === 'single_text' ? self::HTML5_FORMAT : self::DEFAULT_FORMAT;
|
||||
};
|
||||
|
||||
// BC until Symfony 2.3
|
||||
$modelTimezone = function (Options $options) {
|
||||
return $options['data_timezone'];
|
||||
@ -196,7 +200,7 @@ class DateType extends AbstractType
|
||||
'days' => range(1, 31),
|
||||
'widget' => 'choice',
|
||||
'input' => 'datetime',
|
||||
'format' => self::HTML5_FORMAT,
|
||||
'format' => $format,
|
||||
'model_timezone' => $modelTimezone,
|
||||
'view_timezone' => $viewTimezone,
|
||||
// Deprecated timezone options
|
||||
|
@ -809,14 +809,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_date"]
|
||||
[
|
||||
./select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_month"]
|
||||
[./option[@value="2"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_day"]
|
||||
[./option[@value="3"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
]
|
||||
/following-sibling::div
|
||||
[@id="name_time"]
|
||||
@ -849,14 +849,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_date"]
|
||||
[
|
||||
./select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_month"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_day"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
/following-sibling::div
|
||||
[@id="name_time"]
|
||||
@ -889,14 +889,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_date"]
|
||||
[
|
||||
./select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_month"]
|
||||
[./option[@value="2"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_day"]
|
||||
[./option[@value="3"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
]
|
||||
/following-sibling::div
|
||||
[@id="name_time"]
|
||||
@ -928,14 +928,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_date"]
|
||||
[
|
||||
./select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_month"]
|
||||
[./option[@value="2"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_day"]
|
||||
[./option[@value="3"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
]
|
||||
/following-sibling::div
|
||||
[@id="name_time"]
|
||||
@ -1031,14 +1031,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./select
|
||||
[@id="name_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_month"]
|
||||
[./option[@value="2"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value="3"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value="2011"][@selected="selected"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1058,14 +1058,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_month"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1085,14 +1085,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_month"]
|
||||
[./option[@value="1"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value="1"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1110,10 +1110,6 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./input
|
||||
[@id="name_year"]
|
||||
[@type="text"]
|
||||
[@value="2011"]
|
||||
/following-sibling::input
|
||||
[@id="name_month"]
|
||||
[@type="text"]
|
||||
[@value="2"]
|
||||
@ -1121,6 +1117,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_day"]
|
||||
[@type="text"]
|
||||
[@value="3"]
|
||||
/following-sibling::input
|
||||
[@id="name_year"]
|
||||
[@type="text"]
|
||||
[@value="2011"]
|
||||
]
|
||||
[count(./input)=3]
|
||||
'
|
||||
@ -1164,14 +1164,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./select
|
||||
[@id="name_year"]
|
||||
[./option[@value="2000"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_month"]
|
||||
[./option[@value="2"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value="3"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value="2000"][@selected="selected"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1190,10 +1190,6 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
'/div
|
||||
[
|
||||
./select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans][/trans]"]]
|
||||
[./option[@value="1950"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_month"]
|
||||
[./option[@value=""][.="[trans][/trans]"]]
|
||||
[./option[@value="1"][@selected="selected"]]
|
||||
@ -1201,6 +1197,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@id="name_day"]
|
||||
[./option[@value=""][.="[trans][/trans]"]]
|
||||
[./option[@value="1"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][.="[trans][/trans]"]]
|
||||
[./option[@value="1950"][@selected="selected"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
|
@ -510,18 +510,18 @@ class DateTypeTest extends LocalizedTestCase
|
||||
$form = $this->factory->create('date');
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertSame('{{ year }}-{{ month }}-{{ day }}', $view->vars['date_pattern']);
|
||||
$this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']);
|
||||
}
|
||||
|
||||
public function testPassDatePatternToViewDifferentFormat()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'format' => \IntlDateFormatter::LONG,
|
||||
));
|
||||
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertSame('{{ day }}.{{ month }}.{{ year }}', $view->vars['date_pattern']);
|
||||
$this->assertSame('{{ day }}. {{ month }} {{ year }}', $view->vars['date_pattern']);
|
||||
}
|
||||
|
||||
public function testPassDatePatternToViewDifferentPattern()
|
||||
|
Reference in New Issue
Block a user