I am trying to output an error message to a template using
<code>$this->template->error = $val->show_errors();</code>
where $val is a validation class object. What I am getting is sanitized text in my error output rather then an ordered list like I expected. I know I am missing something here but for the life of me I can't find the answer.
I am no expert, but the problems seems to be that the variables within the Template controller
$this->template->somevariable
are sanitized by default. I can not figure out how to not have the template variable sanitized. For a standard controller I saw in the docs the
$view->set('info', $val->show_errors(), false);
functionality, but I can not seem to get it to work for a template variable.
Attached is the full code that I am trying to figure out. In the template I have a message div that catches all of the messages to my users. It is not in the individual view, but rather the master template. I really need to figure this out. I am working on a project for my school district (I am a teacher).
$data = array();
if ($_POST)
{
$val = Validation::forge();
$val->add_field('new_pass', 'New Password', 'required|trim|min_length[4]|max_length[10]|match_field[confirm_pass]');
$val->add_field('confirm_pass', 'Confirm Password', 'required');
if ($val->run())
$this->template->info = 'Password Changed Successfully!';
else
$this->template->error = $val->show_errors();
}
$this->template->content = View::forge('student/password/change', $data, false);
I feel like an idiot. I must have been more tired then I thought last night.
$this->template->set('error', $val->show_errors(), false);
does set non sanitized template variable as per the documentation.
Palm meet face ...