3232 *
3333 * (1) the "model" format required by the form's object
3434 * (2) the "normalized" format for internal processing
35- * (3) the "view" format used for display
35+ * (3) the "view" format used for display simple fields
36+ * or map children model data for compound fields
3637 *
3738 * A date field, for example, may store a date as "Y-m-d" string (1) in the
3839 * object. To facilitate processing in the field, this value is normalized
3940 * to a DateTime object (2). In the HTML representation of your form, a
40- * localized string (3) is presented to and modified by the user.
41+ * localized string (3) may be presented to and modified by the user, or it could be an array of values
42+ * to be mapped to choices fields.
4143 *
4244 * In most cases, format (1) and format (2) will be the same. For example,
4345 * a checkbox field uses a Boolean value for both internal processing and
44- * storage in the object. In these cases you simply need to set a value
46+ * storage in the object. In these cases you simply need to set a view
4547 * transformer to convert between formats (2) and (3). You can do this by
4648 * calling addViewTransformer().
4749 *
4850 * In some cases though it makes sense to make format (1) configurable. To
4951 * demonstrate this, let's extend our above date field to store the value
5052 * either as "Y-m-d" string or as timestamp. Internally we still want to
5153 * use a DateTime object for processing. To convert the data from string/integer
52- * to DateTime you can set a normalization transformer by calling
54+ * to DateTime you can set a model transformer by calling
5355 * addModelTransformer(). The normalized data is then converted to the displayed
5456 * data as described before.
5557 *
@@ -218,7 +220,7 @@ public function getPropertyPath()
218220 }
219221
220222 if (null === $ this ->getName () || '' === $ this ->getName ()) {
221- return ;
223+ return null ;
222224 }
223225
224226 $ parent = $ this ->parent ;
@@ -341,8 +343,8 @@ public function setData($modelData)
341343 $ modelData = $ event ->getData ();
342344 }
343345
344- // Treat data as strings unless a value transformer exists
345- if (!$ this ->config ->getViewTransformers () && !$ this ->config ->getModelTransformers () && is_scalar ( $ modelData )) {
346+ // Treat data as strings unless a transformer exists
347+ if (is_scalar ( $ modelData ) && !$ this ->config ->getViewTransformers () && !$ this ->config ->getModelTransformers ()) {
346348 $ modelData = (string ) $ modelData ;
347349 }
348350
@@ -1068,7 +1070,7 @@ public function createView(FormView $parent = null)
10681070 }
10691071
10701072 /**
1071- * Normalizes the value if a normalization transformer is set.
1073+ * Normalizes the value if a model transformer is set.
10721074 *
10731075 * @param mixed $value The value to transform
10741076 *
@@ -1090,7 +1092,7 @@ private function modelToNorm($value)
10901092 }
10911093
10921094 /**
1093- * Reverse transforms a value if a normalization transformer is set.
1095+ * Reverse transforms a value if a model transformer is set.
10941096 *
10951097 * @param string $value The value to reverse transform
10961098 *
@@ -1114,7 +1116,7 @@ private function normToModel($value)
11141116 }
11151117
11161118 /**
1117- * Transforms the value if a value transformer is set.
1119+ * Transforms the value if a view transformer is set.
11181120 *
11191121 * @param mixed $value The value to transform
11201122 *
@@ -1145,7 +1147,7 @@ private function normToView($value)
11451147 }
11461148
11471149 /**
1148- * Reverse transforms a value if a value transformer is set.
1150+ * Reverse transforms a value if a view transformer is set.
11491151 *
11501152 * @param string $value The value to reverse transform
11511153 *
0 commit comments