public function createFormErrorArray(Form $data)
    {
        $form = [];
        $errors = [];
        foreach ($data->getErrors() as $error) {
            $errors[] = $this->getErrorMessage($error);
        }

        if ($errors) {
            $form['errors'] = $errors;
        }

        $children = [];
        foreach ($data->all() as $child) {
            if ($child instanceof Form) {
                $children[$child->getName()] = $this->createFormErrorArray($child);
            }
        }

        if ($children) {
            $form['children'] = $children;
        }

        return $form;
    }
public function createFormErrorArray(Form $data)
    {
        $form = [];
        $errors = [];
        foreach ($data->getErrors() as $error) {
            $errors[] = $this->getErrorMessage($error);
        }

        if ($errors) {
            $form['errors'] = $errors;
        }

        $children = [];
        foreach ($data->all() as $child) {
            if ($child instanceof Form) {
                $children[$child->getName()] = $this->createFormErrorArray($child);
            }
        }

        if ($children) {
            $form['children'] = $children;
        }

        return $form;
    }
public function createFormErrorArray ( Form $ data ) { $ form = [ ] ; $ errors = [ ] ; foreach ( $ data -> getErrors ( ) as $ error ) { $ errors [ ] = $ this -> getErrorMessage ( $ error ) ; } if ( $ errors ) { $ form [ 'errors' ] = $ errors ; } $ children = [ ] ; foreach ( $ data -> all ( ) as $ child ) { if ( $ child instanceof Form ) { $ children [ $ child -> getName ( ) ] = $ this -> createFormErrorArray ( $ child ) ; } } if ( $ children ) { $ form [ 'children' ] = $ children ; } return $ form ; }
Recursively loops through the form object and returns an array of errors

@param Form $data
@return array
Recursively loops through the form object and returns an array of errors