Skip to content
1 change: 1 addition & 0 deletions UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Form
* Changed `$checkboxes` parameter type of the `CheckboxListMapper::mapFormsToData()` method from `iterable` to `\Traversable`.
* Changed `$radios` parameter type of the `RadioListMapper::mapDataToForms()` method from `iterable` to `\Traversable`.
* Changed `$radios` parameter type of the `RadioListMapper::mapFormsToData()` method from `iterable` to `\Traversable`.
* The default value of the `empty_data` option of the `TextType` has been changed to empty string.

FrameworkBundle
---------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function testLabelOnForm()

public function testLabelDoesNotRenderFieldAttributes()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), null, [
'attr' => [
'class' => 'my&class',
Expand All @@ -47,7 +49,9 @@ public function testLabelDoesNotRenderFieldAttributes()

public function testLabelWithCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), null, [
'label_attr' => [
'class' => 'my&class',
Expand All @@ -64,7 +68,9 @@ public function testLabelWithCustomAttributesPassedDirectly()

public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), 'Custom label', [
'label_attr' => [
'class' => 'my&class',
Expand All @@ -83,6 +89,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => 'Custom label',
]);
$html = $this->renderLabel($form->createView(), null, [
Expand All @@ -103,6 +110,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
public function testLabelHtmlDefaultIsFalse()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => '<b>Bolded label</b>',
]);

Expand All @@ -119,6 +127,7 @@ public function testLabelHtmlDefaultIsFalse()
public function testLabelHtmlIsTrue()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => '<b>Bolded label</b>',
'label_html' => true,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function testLabelOnForm()

public function testLabelDoesNotRenderFieldAttributes()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), null, [
'attr' => [
'class' => 'my&class',
Expand All @@ -51,7 +53,9 @@ public function testLabelDoesNotRenderFieldAttributes()

public function testLabelWithCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), null, [
'label_attr' => [
'class' => 'my&class',
Expand All @@ -68,7 +72,9 @@ public function testLabelWithCustomAttributesPassedDirectly()

public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderLabel($form->createView(), 'Custom label', [
'label_attr' => [
'class' => 'my&class',
Expand All @@ -87,6 +93,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => 'Custom label',
]);
$html = $this->renderLabel($form->createView(), null, [
Expand All @@ -107,6 +114,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
public function testLabelHtmlDefaultIsFalse()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => '<b>Bolded label</b>',
]);

Expand All @@ -123,6 +131,7 @@ public function testLabelHtmlDefaultIsFalse()
public function testLabelHtmlIsTrue()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'label' => '<b>Bolded label</b>',
'label_html' => true,
]);
Expand All @@ -140,6 +149,7 @@ public function testLabelHtmlIsTrue()
public function testHelp()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'help' => 'Help text test!',
]);
$view = $form->createView();
Expand All @@ -157,6 +167,7 @@ public function testHelp()
public function testHelpAttr()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'help' => 'Help text test!',
'help_attr' => [
'class' => 'class-test',
Expand All @@ -177,6 +188,7 @@ public function testHelpAttr()
public function testHelpHtmlDefaultIsFalse()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'help' => 'Help <b>text</b> test!',
]);

Expand Down Expand Up @@ -204,6 +216,7 @@ public function testHelpHtmlDefaultIsFalse()
public function testHelpHtmlIsFalse()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'help' => 'Help <b>text</b> test!',
'help_html' => false,
]);
Expand Down Expand Up @@ -232,6 +245,7 @@ public function testHelpHtmlIsFalse()
public function testHelpHtmlIsTrue()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'help' => 'Help <b>text</b> test!',
'help_html' => true,
]);
Expand Down Expand Up @@ -259,7 +273,9 @@ public function testHelpHtmlIsTrue()

public function testErrors()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$form->addError(new FormError('[trans]Error 1[/trans]'));
$form->addError(new FormError('[trans]Error 2[/trans]'));
$view = $form->createView();
Expand Down Expand Up @@ -292,7 +308,9 @@ public function testErrors()
public function testOverrideWidgetBlock()
{
// see custom_widgets.html.twig
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
]);
$html = $this->renderWidget($form->createView());

$this->assertMatchesXpath($html,
Expand Down Expand Up @@ -1970,7 +1988,9 @@ public function testBirthDayWithPlaceholder()

public function testEmail()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -1986,6 +2006,7 @@ public function testEmail()
public function testEmailWithMaxLength()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', [
'empty_data' => null,
'attr' => ['maxlength' => 123],
]);

Expand Down Expand Up @@ -2017,6 +2038,7 @@ public function testHidden()
public function testDisabled()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
'empty_data' => null,
'disabled' => true,
]);

Expand Down Expand Up @@ -2163,7 +2185,9 @@ public function testRenderNumberWithHtml5NumberType()

public function testPassword()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2177,6 +2201,7 @@ public function testPassword()
public function testPasswordSubmittedWithNotAlwaysEmpty()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, [
'empty_data' => null,
'always_empty' => false,
]);
$form->submit('foo&bar');
Expand All @@ -2194,6 +2219,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty()
public function testPasswordWithMaxLength()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', [
'empty_data' => null,
'attr' => ['maxlength' => 123],
]);

Expand Down Expand Up @@ -2353,7 +2379,10 @@ public function testRadioRowWithHelp()

public function testRange()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, [
'empty_data' => null,
'attr' => ['min' => 5],
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2368,7 +2397,10 @@ public function testRange()

public function testRangeWithMinMaxValues()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5, 'max' => 57]]);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, [
'empty_data' => null,
'attr' => ['min' => 5, 'max' => 57],
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2385,6 +2417,7 @@ public function testRangeWithMinMaxValues()
public function testTextarea()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', [
'empty_data' => null,
'attr' => ['pattern' => 'foo'],
]);

Expand All @@ -2400,7 +2433,9 @@ public function testTextarea()

public function testText()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2416,6 +2451,7 @@ public function testText()
public function testTextWithMaxLength()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', [
'empty_data' => null,
'attr' => ['maxlength' => 123],
]);

Expand All @@ -2432,7 +2468,9 @@ public function testTextWithMaxLength()

public function testSearch()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar');
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar', [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand Down Expand Up @@ -2646,7 +2684,10 @@ public function testTimezoneWithPlaceholder()
public function testUrlWithDefaultProtocol()
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, [
'empty_data' => null,
'default_protocol' => 'http',
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2662,7 +2703,10 @@ public function testUrlWithDefaultProtocol()
public function testUrlWithoutDefaultProtocol()
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => null]);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, [
'empty_data' => null,
'default_protocol' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand Down Expand Up @@ -2740,6 +2784,7 @@ public function testReset()
public function testWidgetAttributes()
{
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [
'empty_data' => null,
'required' => true,
'disabled' => true,
'attr' => ['readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'],
Expand All @@ -2754,6 +2799,7 @@ public function testWidgetAttributes()
public function testWidgetAttributeNameRepeatedIfTrue()
{
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [
'empty_data' => null,
'attr' => ['foo' => true],
]);

Expand Down Expand Up @@ -2791,7 +2837,9 @@ public function testButtonAttributeNameRepeatedIfTrue()
public function testTel()
{
$tel = '0102030405';
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TelType', $tel);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TelType', $tel, [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand All @@ -2806,7 +2854,9 @@ public function testTel()
public function testColor()
{
$color = '#0000ff';
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ColorType', $color);
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ColorType', $color, [
'empty_data' => null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/input
Expand Down
Loading