瀏覽代碼

Simplified serializing to xml of the nested forms.

Deni 14 年之前
父節點
當前提交
2f59b06bca
共有 2 個文件被更改,包括 6 次插入10 次删除
  1. 1 3
      Serializer/Handler/FormErrorHandler.php
  2. 5 7
      Tests/Serializer/xml/nested_form_errors.xml

+ 1 - 3
Serializer/Handler/FormErrorHandler.php

@@ -60,10 +60,8 @@ class FormErrorHandler implements SerializationHandlerInterface
                 $visitor->visitArray($data->getErrors(), $type);
                 $visitor->revertCurrentNode();
 
-                // if has nested form, append children node
                 if ($data->hasChildren()) {
-                    $formNode->appendChild($childrenNode = $visitor->document->createElement('children'));
-                    $visitor->setCurrentNode($childrenNode);
+                    $visitor->setCurrentNode($formNode);
 
                     foreach ($data->getChildren() as $child) {
                         $this->serialize($visitor, $child, $type, $visited);

+ 5 - 7
Tests/Serializer/xml/nested_form_errors.xml

@@ -3,11 +3,9 @@
   <errors>
     <entry><![CDATA[This is the form error]]></entry>
   </errors>
-  <children>
-    <form name="bar">
-      <errors>
-        <entry><![CDATA[Error of the child form]]></entry>
-      </errors>
-    </form>
-  </children>
+  <form name="bar">
+    <errors>
+      <entry><![CDATA[Error of the child form]]></entry>
+    </errors>
+  </form>
 </form>