[eluser]misterdonut[/eluser]
i have a template and i would like to know how to properly use it together with a validation class.
Code:
function index()
{
$css = "<link href='".base_url()."assets/css/login.css' rel='stylesheet' type='text/css' />";
$css .= "<link href='".base_url()."assets/css/forms.css' rel='stylesheet' type='text/css' />";
$login = form_open('user/login')."
<div id='login'>
<div>
<ul>
<li>
<div>
<h3 for='username'>Username</h3>
<input id='input' type='text' name='username'>
</div>
</li>
<li>
<div>
<h3 for='password'>Password</h3>
<input id='input' type='password' name='password'>
</div>
</li>
<li>
<div>
<input type='image' id='loginsubmit' src='".base_url()."assets/images/login.png' value='Log me in' >
</div>
</li>
</ul>
</div>
</div>
</form>
";
$this->template->write('title', 'Portal Login');
$this->template->write('head', $css);
$this->template->write('content', $login);
$this->template->render($region = NULL, $buffer = FALSE, $parse = FALSE);
}
please give me comments on how to implement my validation together with templating. i'm new to both libraries TIA.
my problem is how to get the previous value of the region 'content' and reuse it and repopulate my form.
Code:
function login()
{
$this->load->library('validation');
$rules['username'] = "required|xss_clean";
$rules['password'] = "required|md5";
$this->validation->set_rules($rules);
if ($this->validation->run() == FALSE){
//error msg with the form and previous values
//$this->template->render($region = NULL, $buffer = FALSE, $parse = FALSE);
echo "fail::";
}else{
//login
redirect('user/main');
}
}