3131 *
3232 * (1) the "model" format required by the form's object
3333 * (2) the "normalized" format for internal processing
34- * (3) the "view" format used for display
34+ * (3) the "view" format used for display simple fields
35+ * or map children model data for compound fields
3536 *
3637 * A date field, for example, may store a date as "Y-m-d" string (1) in the
3738 * object. To facilitate processing in the field, this value is normalized
3839 * to a DateTime object (2). In the HTML representation of your form, a
39- * localized string (3) is presented to and modified by the user.
40+ * localized string (3) may be presented to and modified by the user, or it could be an array of values
41+ * to be mapped to choices fields.
4042 *
4143 * In most cases, format (1) and format (2) will be the same. For example,
4244 * a checkbox field uses a Boolean value for both internal processing and
43- * storage in the object. In these cases you simply need to set a value
45+ * storage in the object. In these cases you simply need to set a view
4446 * transformer to convert between formats (2) and (3). You can do this by
4547 * calling addViewTransformer().
4648 *
4749 * In some cases though it makes sense to make format (1) configurable. To
4850 * demonstrate this, let's extend our above date field to store the value
4951 * either as "Y-m-d" string or as timestamp. Internally we still want to
5052 * use a DateTime object for processing. To convert the data from string/integer
51- * to DateTime you can set a normalization transformer by calling
53+ * to DateTime you can set a model transformer by calling
5254 * addModelTransformer(). The normalized data is then converted to the displayed
5355 * data as described before.
5456 *
@@ -217,7 +219,7 @@ public function getPropertyPath()
217219 }
218220
219221 if (null === $ this ->getName () || '' === $ this ->getName ()) {
220- return ;
222+ return null ;
221223 }
222224
223225 $ parent = $ this ->parent ;
@@ -340,8 +342,8 @@ public function setData($modelData)
340342 $ modelData = $ event ->getData ();
341343 }
342344
343- // Treat data as strings unless a value transformer exists
344- if (!$ this ->config ->getViewTransformers () && !$ this ->config ->getModelTransformers () && is_scalar ( $ modelData )) {
345+ // Treat data as strings unless a transformer exists
346+ if (is_scalar ( $ modelData ) && !$ this ->config ->getViewTransformers () && !$ this ->config ->getModelTransformers ()) {
345347 $ modelData = (string ) $ modelData ;
346348 }
347349
@@ -1016,7 +1018,7 @@ public function createView(FormView $parent = null)
10161018 }
10171019
10181020 /**
1019- * Normalizes the value if a normalization transformer is set.
1021+ * Normalizes the value if a model transformer is set.
10201022 *
10211023 * @param mixed $value The value to transform
10221024 *
@@ -1038,7 +1040,7 @@ private function modelToNorm($value)
10381040 }
10391041
10401042 /**
1041- * Reverse transforms a value if a normalization transformer is set.
1043+ * Reverse transforms a value if a model transformer is set.
10421044 *
10431045 * @param string $value The value to reverse transform
10441046 *
@@ -1062,7 +1064,7 @@ private function normToModel($value)
10621064 }
10631065
10641066 /**
1065- * Transforms the value if a value transformer is set.
1067+ * Transforms the value if a view transformer is set.
10661068 *
10671069 * @param mixed $value The value to transform
10681070 *
@@ -1093,7 +1095,7 @@ private function normToView($value)
10931095 }
10941096
10951097 /**
1096- * Reverse transforms a value if a value transformer is set.
1098+ * Reverse transforms a value if a view transformer is set.
10971099 *
10981100 * @param string $value The value to reverse transform
10991101 *
0 commit comments