changes to view class to have error collector.
This commit is contained in:
parent
78301fb8c7
commit
0d10ab740b
|
@ -31,6 +31,17 @@ public function add($attribute, $message)
|
||||||
$this->messages[$attribute][] = $message;
|
$this->messages[$attribute][] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if errors exist for an attribute.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function has($attribute)
|
||||||
|
{
|
||||||
|
return $this->first($attribute) !== '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first error message for an attribute.
|
* Get the first error message for an attribute.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,16 @@ public function __construct($view, $data = array())
|
||||||
{
|
{
|
||||||
$this->view = $view;
|
$this->view = $view;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
|
||||||
|
// -----------------------------------------------------
|
||||||
|
// Every view has an error collector. This makes it
|
||||||
|
// convenient to check for any validation errors without
|
||||||
|
// worrying if the error collector is instantiated.
|
||||||
|
//
|
||||||
|
// If an error collector is in the session, it will
|
||||||
|
// be used as the error collector for the view.
|
||||||
|
// -----------------------------------------------------
|
||||||
|
$this->data['errors'] = (Config::get('session.driver') != '' and Session::has('errors')) ? Session::get('errors') : new Validation\Error_Collector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue