File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
src/Symfony/Component/Form
Extension/Core/DataTransformer
Tests/Extension/Core/DataTransformer Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public function reverseTransform($array)
64
64
$ emptyKeys = array ();
65
65
66
66
foreach ($ this ->keys as $ key ) {
67
- if (! empty ($ array [$ key ])) {
67
+ if (isset ($ array [$ key ]) && '' !== $ array [ $ key ] && false !== $ array [ $ key ] && array () !== $ array [ $ key ] ) {
68
68
if ($ array [$ key ] !== $ result ) {
69
69
throw new TransformationFailedException (
70
70
'All values in the array should be the same '
Original file line number Diff line number Diff line change @@ -82,6 +82,29 @@ public function testReverseTransformCompletelyNull()
82
82
$ this ->assertNull ($ this ->transformer ->reverseTransform ($ input ));
83
83
}
84
84
85
+ public function testReverseTransformEmptyArray ()
86
+ {
87
+ $ input = array (
88
+ 'a ' => array (),
89
+ 'b ' => array (),
90
+ 'c ' => array (),
91
+ );
92
+
93
+ $ this ->assertNull ($ this ->transformer ->reverseTransform ($ input ));
94
+ }
95
+
96
+
97
+ public function testReverseTransformZeroString ()
98
+ {
99
+ $ input = array (
100
+ 'a ' => '0 ' ,
101
+ 'b ' => '0 ' ,
102
+ 'c ' => '0 '
103
+ );
104
+
105
+ $ this ->assertSame ('0 ' , $ this ->transformer ->reverseTransform ($ input ));
106
+ }
107
+
85
108
/**
86
109
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
87
110
*/
You can’t perform that action at this time.
0 commit comments