8000 [Form] Deprecated FormTypeInterface::getName() · symfony/symfony@de9a855 · GitHub
[go: up one dir, main page]

Skip to content

Commit de9a855

Browse files
committed
[Form] Deprecated FormTypeInterface::getName()
1 parent dd7583d commit de9a855

File tree

92 files changed

+1811
-965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1811
-965
lines changed

UPGRADE-2.8.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,56 @@ Form
4242
private $author;
4343
}
4444
```
45+
46+
* Type names were deprecated and will be removed in Symfony 3.0. Instead of
47+
referencing types by name, you should reference them by their
48+
fully-qualified class name (FQCN) instead. With PHP 5.5 or later, you should
49+
use the "class" constant for that:
50+
51+
Before:
52+
53+
```php
54+
$form = $this->createForm('form')
55+
->add('name', 'text')
56+
->add('age', 'integer')
57+
->getForm();
58+
```
59+
60+
After:
61+
62+
```php
63+
use Symfony\Component\Form\Extension\Core\Type\FormType;
64+
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
65+
use Symfony\Component\Form\Extension\Core\Type\TextType;
66+
67+
$form = $this->createForm(FormType::class)
68+
->add('name', TextType::class)
69+
->add('age', IntegerType::class)
70+
->getForm();
71+
```
72+
73+
As a further consequence, the method `FormTypeInterface::getName()` was
74+
deprecated and will be removed in Symfony 3.0. You should remove this method
75+
from your form types.
76+
77+
If you define your form types in the Dependency Injection configuration, you
78+
should further remove the "alias" attribute:
79+
80+
Before:
81+
82+
```xml
83+
<service id="my.type" class="Vendor\Type\MyType">
84+
<tag name="form.type" alias="mytype" />
85+
</service>
86+
```
87+
88+
After:
89+
90+
```xml
91+
<service id="my.type" class="Vendor\Type\MyType">
92+
<tag name="form.type" />
93+
</service>
94+
```
4595

4696
Translator
4797
----------

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ public static function createChoiceName($choice, $key, $value)
9494
* Gets important parts from QueryBuilder that will allow to cache its results.
9595
* For instance in ORM two query builders with an equal SQL string and
9696
* equal parameters are considered to be equal.
97-
*
97+
*
9898
* @param object $queryBuilder
99-
*
99+
*
100100
* @return array|false Array with important QueryBuilder parts or false if
101101
* they can't be determined
102-
*
102+
*
103103
* @internal This method is public to be usable as callback. It should not
104104
* be used in user code.
105105
*/
@@ -335,6 +335,6 @@ abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class
335335

336336
public function getParent()
337337
{
338-
return 'choice';
338+
return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
339339
}
340340
}

0 commit comments

Comments
 (0)
0