8000 minor #9804 [Form] Update UPGRADE-2.3.md to account for #9388 (ureimers) · benji07/symfony@3ae496e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ae496e

Browse files
committed
minor symfony#9804 [Form] Update UPGRADE-2.3.md to account for symfony#9388 (ureimers)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes symfony#9804). Discussion ---------- [Form] Update UPGRADE-2.3.md to account for symfony#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 symfony#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 symfony#9388
2 parents 6e0848d + 8a73974 commit 3ae496e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

UPGRADE-2.3.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,32 @@ Form
170170
$form = $builder->getForm();
171171
```
172172

173+
* Previously, when the "data" option of a field was set to `null` and the
174+
containing form was mapped to an object, the field would receive the data
175+
from the object as default value. This functionality was unintended and fixed
176+
to use `null` as default value in Symfony 2.3.
177+
178+
In cases where you made use of the previous behavior, you should now remove
179+
the "data" option altogether.
180+
181+
Before:
182+
183+
```
184+
$builder->add('field', 'text', array(
185+
'data' => $defaultData ?: null,
186+
));
187+
```
188+
189+
After:
190+
191+
```
192+
$options = array();
193+
if ($defaultData) {
194+
$options['data'] = $defaultData;
195+
}
196+
$builder->add('field', 'text', $options);
197+
```
198+
173199
PropertyAccess
174200
--------------
175201

0 commit comments

Comments
 (0)
0