Welcome Guest, Not a member yet? Register   Sign In
how to implement templating
#1

[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>                                
                                &lt;input id='input' type='text' name='username'&gt;
                                </div>
                            </li>                            
                            <li>
                                <div>
                                <h3 for='password'>Password</h3>                                
                                &lt;input id='input' type='password' name='password'&gt;
                                </div>
                            </li>
                            <li>
                                <div>                            
                                &lt;input type='image' id='loginsubmit' src='".base_url()."assets/images/login.png' value='Log me in'    &gt;
                                </div>
                            </li>
                        
                        </ul>
                        </div>
                    </div>
                &lt;/form&gt;
                ";
        $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');
        }    
    }


Messages In This Thread
how to implement templating - by El Forum - 08-27-2008, 02:35 AM
how to implement templating - by El Forum - 08-27-2008, 04:52 AM
how to implement templating - by El Forum - 08-27-2008, 07:53 AM
how to implement templating - by El Forum - 08-27-2008, 09:31 AM
how to implement templating - by El Forum - 08-27-2008, 07:23 PM
how to implement templating - by El Forum - 08-27-2008, 10:48 PM
how to implement templating - by El Forum - 08-28-2008, 01:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB