Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9119e44

Browse files
committed
[Form] Fixed wrong usages of the "text" type
1 parent da43309 commit 9119e44

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Symfony/Component/Form/Form.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Form\Exception\TransformationFailedException;
1818
use Symfony\Component\Form\Exception\LogicException;
1919
use Symfony\Component\Form\Exception\OutOfBoundsException;
20+
use Symfony\Component\Form\Extension\Core\Type\TextType;
2021
use Symfony\Component\Form\Util\FormUtil;
2122
use Symfony\Component\Form\Util\InheritDataAwareIterator;
2223
use Symfony\Component\Form\Util\OrderedHashMap;
@@ -910,7 +911,7 @@ public function add($child, $type = null, array $options = array())
910911
$options['auto_initialize'] = false;
911912

912913
if (null === $type && null === $this->config->getDataClass()) {
913-
$type = 'text';
914+
$type = TextType::class;
914915
}
915916

916917
if (null === $type) {

src/Symfony/Component/Form/Tests/CompoundFormTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests;
1313

1414
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
15+
use Symfony\Component\Form\Extension\Core\Type\TextType;
1516
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
1617
use Symfony\Component\Form\FormError;
1718
use Symfony\Component\Form\Forms;
@@ -172,13 +173,13 @@ public function testAddUsingNameAndType()
172173

173174
$this->factory->expects($this->once())
174175
->method('createNamed')
175-
->with('foo', 'text', null, array(
176+
->with('foo', TextType::class, null, array(
176177
'bar' => 'baz',
177178
'auto_initialize' => false,
178179
))
179180
->will($this->returnValue($child));
180181

181-
$this->form->add('foo', 'text', array('bar' => 'baz'));
182+
$this->form->add('foo', TextType::class, array('bar' => 'baz'));
182183

183184
$this->assertTrue($this->form->has('foo'));
184185
$this->assertSame($this->form, $child->getParent());
@@ -191,14 +192,14 @@ public function testAddUsingIntegerNameAndType()
191192

192193
$this->factory->expects($this->once())
193194
->method('createNamed')
194-
->with('0', 'text', null, array(
195+
->with('0', TextType::class, null, array(
195196
'bar' => 'baz',
196197
'auto_initialize' => false,
197198
))
198199
->will($this->returnValue($child));
199200

200201
// in order to make casting unnecessary
201-
$this->form->add(0, 'text', array('bar' => 'baz'));
202+
$this->form->add(0, TextType::class, array('bar' => 'baz'));
202203

203204
$this->assertTrue($this->form->has(0));
204205
$this->assertSame($this->form, $child->getParent());
@@ -211,7 +212,7 @@ public function testAddWithoutType()
211212

212213
$this->factory->expects($this->once())
213214
->method('createNamed')
214-
->with('foo', 'text')
215+
->with('foo', TextType::class)
215216
->will($this->returnValue($child));
216217

217218
$this->form->add('foo');

0 commit comments

Comments
 (0)