Skip to content

Commit

Permalink
minor #9804 [Form] Update UPGRADE-2.3.md to account for #9388 (ureimers)
Browse files Browse the repository at this point in the history
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9804).

Discussion
----------

[Form] Update UPGRADE-2.3.md to account for #9388

Added documentation for how to correctly pre-fill a form using the form's `data` option.
The "old" and also wrong way of doing it broke with Symfony 2.3.7 (with #9388 to be precise) and this short documentation should help others to fix the problem and do it right.

Commits
-------

5e06535 [Form] Update UPGRADE-2.3.md to account for #9388
  • Loading branch information
fabpot committed Jan 6, 2014
2 parents 6e0848d + 8a73974 commit 3ae496e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions UPGRADE-2.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,32 @@ Form
$form = $builder->getForm();
```

* Previously, when the "data" option of a field was set to `null` and the
containing form was mapped to an object, the field would receive the data
from the object as default value. This functionality was unintended and fixed
to use `null` as default value in Symfony 2.3.

In cases where you made use of the previous behavior, you should now remove
the "data" option altogether.

Before:

```
$builder->add('field', 'text', array(
'data' => $defaultData ?: null,
));
```

After:

```
$options = array();
if ($defaultData) {
$options['data'] = $defaultData;
}
$builder->add('field', 'text', $options);
```

PropertyAccess
--------------

Expand Down

0 comments on commit 3ae496e

Please sign in to comment.