protected function cleanErrors(Widget $widget, $ignoreErrors = false)
    {
        if (!$ignoreErrors) {
            return;
        }

        // Clean the errors array and fix up the CSS class.
        $reflectionPropError = new \ReflectionProperty(\get_class($widget), 'arrErrors');
        $reflectionPropError->setAccessible(true);
        $reflectionPropError->setValue($widget, []);

        $reflectionPropClass = new \ReflectionProperty(\get_class($widget), 'strClass');
        $reflectionPropClass->setAccessible(true);
        $reflectionPropClass->setValue($widget, \str_replace('error', '', $reflectionPropClass->getValue($widget)));
    }