Reflected the change of the choice_value option in the Upgrade information
This commit is contained in:
parent
2b8c9f8269
commit
28675c990b
@ -186,6 +186,41 @@ Form
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* In Symfony 2.7 a small BC break was introduced with the new choices_as_values
|
||||||
|
option. In order to have the choice values populated to the html value attribute
|
||||||
|
you had to define the choice_value option. This is now not any more needed.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form->add('status', 'choice', array(
|
||||||
|
'choices' => array(
|
||||||
|
'Enabled' => Status::ENABLED,
|
||||||
|
'Disabled' => Status::DISABLED,
|
||||||
|
'Ignored' => Status::IGNORED,
|
||||||
|
),
|
||||||
|
'choices_as_values' => true,
|
||||||
|
// important if you rely on your option value attribute (e.g. for JavaScript)
|
||||||
|
// this will keep the same functionality as before
|
||||||
|
'choice_value' => function ($choice) {
|
||||||
|
return $choice;
|
||||||
|
},
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
|
After (Symfony 2.8+):
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form->add('status', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'Enabled' => Status::ENABLED,
|
||||||
|
'Disabled' => Status::DISABLED,
|
||||||
|
'Ignored' => Status::IGNORED,
|
||||||
|
),
|
||||||
|
'choices_as_values' => true
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
* Returning type instances from `FormTypeInterface::getParent()` is deprecated
|
* Returning type instances from `FormTypeInterface::getParent()` is deprecated
|
||||||
and will not be supported anymore in Symfony 3.0. Return the fully-qualified
|
and will not be supported anymore in Symfony 3.0. Return the fully-qualified
|
||||||
class name of the parent type class instead.
|
class name of the parent type class instead.
|
||||||
|
@ -366,6 +366,42 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* In Symfony 2.7 a small BC break was introduced with the new choices_as_values
|
||||||
|
option. In order to have the choice values populated to the html value attribute
|
||||||
|
you had to define the choice_value option. This is now not any more needed.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form->add('status', 'choice', array(
|
||||||
|
'choices' => array(
|
||||||
|
'Enabled' => Status::ENABLED,
|
||||||
|
'Disabled' => Status::DISABLED,
|
||||||
|
'Ignored' => Status::IGNORED,
|
||||||
|
),
|
||||||
|
// choices_as_values defaults to true in Symfony 3.0
|
||||||
|
// and setting it to anything else is deprecated as of 3.0
|
||||||
|
'choices_as_values' => true,
|
||||||
|
// important if you rely on your option value attribute (e.g. for JavaScript)
|
||||||
|
// this will keep the same functionality as before
|
||||||
|
'choice_value' => function ($choice) {
|
||||||
|
return $choice;
|
||||||
|
},
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$form->add('status', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'Enabled' => Status::ENABLED,
|
||||||
|
'Disabled' => Status::DISABLED,
|
||||||
|
'Ignored' => Status::IGNORED,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
* The `request` service was removed. You must inject the `request_stack`
|
* The `request` service was removed. You must inject the `request_stack`
|
||||||
service instead.
|
service instead.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user