public function getErrorMessages(FormInterface $form, bool $useLabels = false, array $errors = []):array
    {
        if ($form->count() > 0) {
            foreach ($form->all() as $child) {
                if (!$child->isValid()) {
                    $errors = $this->getErrorMessages($child, $useLabels, $errors);
                }
            }
        }

        foreach ($form->getErrors() as $error) {
            if ($useLabels) {
                $fieldNameData = $this->getErrorFormLabel($form);
            } else {
                $fieldNameData = $this->getErrorFormId($form);
            }

            $fieldName = $fieldNameData;

            if ($useLabels) {
                /**
                 * @ignore
                 */
                $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
            }

            $errors[$fieldName] = $error->getMessage();
        }

        return $errors;
    }