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
@@ -1014,7 +1016,7 @@ public function createView(FormView $parent = null)
10141016 }
10151017
10161018 /**
1017- * Normalizes the value if a normalization transformer is set.
1019+ * Normalizes the value if a model transformer is set.
10181020 *
10191021 * @param mixed $value The value to transform
10201022 *
@@ -1036,7 +1038,7 @@ private function modelToNorm($value)
10361038 }
10371039
10381040 /**
1039- * Reverse transforms a value if a normalization transformer is set.
1041+ * Reverse transforms a value if a model transformer is set.
10401042 *
10411043 * @param string $value The value to reverse transform
10421044 *
@@ -1060,7 +1062,7 @@ private function normToModel($value)
10601062 }
10611063
10621064 /**
1063- * Transforms the value if a value transformer is set.
1065+ * Transforms the value if a view transformer is set.
10641066 *
10651067 * @param mixed $value The value to transform
10661068 *
@@ -1091,7 +1093,7 @@ private function normToView($value)
10911093 }
10921094
10931095 /**
1094- * Reverse transforms a value if a value transformer is set.
1096+ * Reverse transforms a value if a view transformer is set.
10951097 *
10961098 * @param string $value The value to reverse transform
10971099 *
0 commit comments