diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md index d8314e023c..3e76e8ac76 100644 --- a/UPGRADE-2.1.md +++ b/UPGRADE-2.1.md @@ -480,6 +480,43 @@ )); ``` + * The "data_class" option now *must* be set if a form maps to an object. If + you leave it empty, the form will expect an array or a scalar value and + fail with a corresponding exception. + + Likewise, if a form maps to an array, the option *must* be left empty now. + + * The mapping of property paths to arrays has changed. + + Previously, a property path "street" mapped to both a field `$street` of + a class (or its accessors `getStreet()` and `setStreet()`) and an index + `['street']` of an array or an object implementing `\ArrayAccess`. + + Now, the property path "street" only maps to a class field (or accessors), + while the property path "[street]" only maps to indices. + + If you defined property paths manually in the "property_path" option, you + should revise them and adjust them if necessary. + + Before: + + ``` + $builder->add('name', 'text', array( + 'property_path' => 'address.street', + )); + ``` + + After (if the address object is an array): + + ``` + $builder->add('name', 'text', array( + 'property_path' => 'address[street]', + )); + ``` + + If address is an object in this case, the code given in "Before" + works without changes. + ### Validator * The methods `setMessage()`, `getMessageTemplate()` and diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index bc4b136e41..b78db354a4 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -71,3 +71,5 @@ CHANGELOG * labels don't display field attributes anymore. Label attributes can be passed in the "label_attr" option/variable * added option "mapped" which should be used instead of setting "property_path" to false + * "data_class" now *must* be set if a form maps to an object and should be left empty otherwise + * improved error mapping on forms