Skip to content

Commit 2f59b06

Browse files
committed
Simplified serializing to xml of the nested forms.
1 parent 78e021e commit 2f59b06

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Serializer/Handler/FormErrorHandler.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ public function serialize(VisitorInterface $visitor, $data, $type, &$handled)
6060
$visitor->visitArray($data->getErrors(), $type);
6161
$visitor->revertCurrentNode();
6262

63-
// if has nested form, append children node
6463
if ($data->hasChildren()) {
65-
$formNode->appendChild($childrenNode = $visitor->document->createElement('children'));
66-
$visitor->setCurrentNode($childrenNode);
64+
$visitor->setCurrentNode($formNode);
6765

6866
foreach ($data->getChildren() as $child) {
6967
$this->serialize($visitor, $child, $type, $visited);

Tests/Serializer/xml/nested_form_errors.xml

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
<errors>
44
<entry><![CDATA[This is the form error]]></entry>
55
</errors>
6-
<children>
7-
<form name="bar">
8-
<errors>
9-
<entry><![CDATA[Error of the child form]]></entry>
10-
</errors>
11-
</form>
12-
</children>
6+
<form name="bar">
7+
<errors>
8+
<entry><![CDATA[Error of the child form]]></entry>
9+
</errors>
10+
</form>
1311
</form>

0 commit comments

Comments
 (0)