public function getFormattedError($name)
{
if (!$this->hasErrors($name)) {
// If the form element does not have any errors, return
// an emptry string.
return '';
}
// Get the errors from the session.
$errors = $this->getSessionStore()->get('errors');
// Return the formatted error message, if the form element has any.
return $errors->first($this->transformKey($name), $this->help(':message'));
}