File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/Symfony/Component/Form Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -720,6 +720,36 @@ public function getErrors()
720
720
return $ this ->errors ;
721
721
}
722
722
723
+ /**
724
+ * Returns a string representation of all form errors (including children errors).
725
+ *
726
+ * This method should only be used to help debug a form.
727
+ *
728
+ * @param integer $level The indentation level (used internally)
729
+ *
730
+ * @return string A string representation of all errors
731
+ */
732
+ public function getErrorsAsString ($ level = 0 )
733
+ {
734
+ $ errors = '' ;
735
+ foreach ($ this ->errors as $ error ) {
736
+ $ errors .= str_repeat (' ' , $ level ).'ERROR: ' .$ error ->getMessageTemplate ()."\n" ;
737
+ }
738
+
739
+ if ($ this ->hasChildren ()) {
740
+ foreach ($ this ->children as $ key => $ child ) {
741
+ $ errors .= str_repeat (' ' , $ level ).$ key .": \n" ;
742
+ if ($ err = $ child ->getErrorsAsString ($ level + 4 )) {
743
+ $ errors .= $ err ;
744
+ } else {
745
+ $ errors .= str_repeat (' ' , $ level + 4 )."No errors \n" ;
746
+ }
747
+ }
748
+ }
749
+
750
+ return $ errors ;
751
+ }
752
+
723
753
/**
724
754
* Returns the DataTransformers.
725
755
*
You can’t perform that action at this time.
0 commit comments