src/Forms/Form.php
public function error(string $name = '', bool $first = false)
    {
        $errors = $this->errors();

        if (empty($name)) {
            // Return all errors messages by default if the
            // name argument is not specified.
            return $errors->all();
        }

        $field = $this->repository->getFieldByName($name);

        if ($first) {
            return $errors->first($field->getName());
        }

        return $errors->get($field->getName());
    }
public function error(string $name = '', bool $first = false)
    {
        $errors = $this->errors();

        if (empty($name)) {
            // Return all errors messages by default if the
            // name argument is not specified.
            return $errors->all();
        }

        $field = $this->repository->getFieldByName($name);

        if ($first) {
            return $errors->first($field->getName());
        }

        return $errors->get($field->getName());
    }
public function error ( string $ name = '' , bool $ first = false ) { $ errors = $ this -> errors ( ) ; if ( empty ( $ name ) ) { // Return all errors messages by default if the // name argument is not specified. return $ errors -> all ( ) ; } $ field = $ this -> repository -> getFieldByName ( $ name ) ; if ( $ first ) { return $ errors -> first ( $ field -> getName ( ) ) ; } return $ errors -> get ( $ field -> getName ( ) ) ; }
Return error messages for a specific field.
By setting the second parameter to true, a user
can fetch the first error message only on the
mentioned field.

@param string $name
@param bool   $first

@return string|array
Return error messages for a specific field . By setting the second parameter to true a user can fetch the first error message only on the mentioned field .