private function getErrors(Form $form)
    {
        $errors = array();

        if ($form->isSubmitted() && $form->isValid()) {
            return $errors;
        }

        $id = $form->createView()->vars['id'];

        foreach ($form->getErrors() as $error) {

            if (!isset($errors[$id])) {
                $errors[$id] = array();
            }

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

        foreach ($form->all() as $child) {
            $errors = array_merge($this->getErrors($child), $errors);
        }

        return $errors;
    }