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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Reflected the change of the choice_value option in the Upgrade inform…
…ation
  • Loading branch information
peterrehm committed Dec 18, 2015
commit 28675c990b26c1cb8c301772cef79da463492ef9
35 changes: 35 additions & 0 deletions UPGRADE-2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
and will not be supported anymore in Symfony 3.0. Return the fully-qualified
class name of the parent type class instead.
Expand Down
36 changes: 36 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,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`
service instead.
Expand Down