Errors that does not belong to any component

Keeehi
Member | 36
+
0
-

Hi,
I would like to ask how to get form errors, that are not attached to any components in the form but to the form itself.
One approach might be to get all components of form, get all their errors, then get all errors of the form and do the diff of those two arrays. But it won't work if the error of the whole form is the same as the error of some component.

Other approach is to use reflection, but that is ugly as hell

$prop = \array_values(\array_filter((new \ReflectionClass($form))->getParentClass()->getProperties(), function($property, $key){return $property->getName() === "errors";}, ARRAY_FILTER_USE_BOTH))[0];
$prop->setAccessible(true);
var_dump($prop->getValue($form));

Does someone know, how to do it properly?
Thanks

nightfish
Member | 472
+
0
-

Would $form->getOwnErrors() not work?

Keeehi
Member | 36
+
0
-

Yes, that is exactly what I had in mind but unfortunately didn't know about that. Thanks