Welcome Guest, Not a member yet? Register   Sign In
Validation library/Helper form
#6

[eluser]roj[/eluser]
Sorry reading this on phone just isn't as good as on a computer...

you should be setting the form_helper data after the validation is run ie something like this:
Code:
$rules['fname'] = "trim|required|min_length[5]|max_length[48]|xss_clean";
    $rules['femail'] = "trim|required|valid_email";
    $rules['fcomments'] = "trim|required|min_length[16]|max_length[1024]|xss_clean";

    $this->validation->set_error_delimiters('<li>', '</li>');
    $this->validation->set_rules($rules);

    # set data
    $data["fname"] = "Name";
    $data["femail"] = "E-mail address";
    $data["fcomments"] = "Comments";
    $this->validation->set_fields($data);

    if ($this->validation->run() == FALSE)
    {
        $data["fname"] = array('name' => 'fname', 'id' => 'fname', 'class' => ($this->validation->fname_error<>"") ? 'textbox error' : 'textbox', 'value' => $this->validation->fname);
        $data["femail"] = array('name' => 'femail', 'id' => 'femail', 'class' => 'textbox', 'value' => $this->validation->femail);
        $data["fcomments"]=array('name' => 'fcomments', 'rows' => 5, 'cols' => 80, 'value' => $this->validation->fcomments);
        
        $this->load->view('form', $data);
    }
    else
    {
        $this->load->view('formsuccess');
    }


Messages In This Thread
Validation library/Helper form - by El Forum - 10-20-2008, 02:30 PM
Validation library/Helper form - by El Forum - 10-20-2008, 03:32 PM
Validation library/Helper form - by El Forum - 10-20-2008, 03:40 PM
Validation library/Helper form - by El Forum - 10-20-2008, 04:47 PM
Validation library/Helper form - by El Forum - 10-20-2008, 04:51 PM
Validation library/Helper form - by El Forum - 10-20-2008, 04:57 PM
Validation library/Helper form - by El Forum - 10-21-2008, 02:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB