Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc749a6

Browse filesBrowse files
committed
bug #14715 [Form] Check instance of FormBuilderInterface instead of FormBuilder (dosten)
This PR was merged into the 2.3 branch. Discussion ---------- [Form] Check instance of FormBuilderInterface instead of FormBuilder | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14714 | License | MIT | Doc PR | - Commits ------- 44469d0 Check instance of FormBuilderInterface instead of FormBuilder
2 parents ff0cb41 + 44469d0 commit cc749a6
Copy full SHA for cc749a6

File tree

Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed

‎src/Symfony/Component/Form/FormBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormBuilder.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function add($child, $type = null, array $options = array())
6262
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
6363
}
6464

65-
if ($child instanceof self) {
65+
if ($child instanceof FormBuilderInterface) {
6666
$this->children[$child->getName()] = $child;
6767

6868
// In case an unresolved child with the same name exists
@@ -72,7 +72,7 @@ public function add($child, $type = null, array $options = array())
7272
}
7373

7474
if (!is_string($child) && !is_int($child)) {
75-
throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormBuilder');
75+
throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormBuilderInterface');
7676
}
7777

7878
if (null !== $type && !is_string($type) && !$type instanceof FormTypeInterface) {

‎src/Symfony/Component/Form/Tests/FormBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/FormBuilderTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use Symfony\Component\Form\ButtonBuilder;
1415
use Symfony\Component\Form\FormBuilder;
16+
use Symfony\Component\Form\SubmitButtonBuilder;
1517

1618
class FormBuilderTest extends \PHPUnit_Framework_TestCase
1719
{
@@ -154,6 +156,12 @@ public function testCreateNoTypeNo()
154156
$this->builder->create('foo');
155157
}
156158

159+
public function testAddButton()
160+
{
161+
$this->builder->add(new ButtonBuilder('reset'));
162+
$this->builder->add(new SubmitButtonBuilder('submit'));
163+
}
164+
157165
public function testGetUnknown()
158166
{
159167
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.