Bootstrapper\Form::hasErrors PHP Method

hasErrors() public method

Determine whether the form element with the given name has any validation errors.
public hasErrors ( string $name ) : boolean
$name string
return boolean
    public function hasErrors($name)
    {
        $session = $this->getSessionStore();
        if (is_null($session) || !$session->has('errors')) {
            // If the session is not set, or the session doesn't contain
            // any errors, the form element does not have any errors
            // applied to it.
            return false;
        }
        // Get the errors from the session.
        $errors = $session->get('errors');
        // Check if the errors contain the form element with the given name.
        return $errors->has($this->transformKey($name));
    }

Usage Example

Example #1
0
 /**
  * Determine whether the form element with the given name
  * has any validation errors.
  *
  * @param string $name
  * @return bool 
  * @static 
  */
 public static function hasErrors($name)
 {
     return \Bootstrapper\Form::hasErrors($name);
 }