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

Upgrade information for the choice_value option #16849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2015
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 35 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 36 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.