Welcome Guest, Not a member yet? Register   Sign In
How to pass multiple values from view->controller->model
#7

[eluser]Eric Cope[/eluser]
In your view, I would do this...
Code:
<?php echo $this->validation->error_string; // this echos the error string from validation?>
<?=form_open('blog/do_search');?>
<input type="text" value="<?=$this->validation->fname;?>" name="fname"></input>
<input type="submit" value="search the blog"></input>
</form>

in your controller...
Code:
<?php
    $this->validation->set_error_delimiters('<div id="errorLogin">', '</div>');
    $rules['fname'] = "trim|required|max_length[100]|xss_clean|..."; / /add more if necessary
    $this->validation->set_rules($rules);
    $fields['fname'] = "First Name";
    $this->validation->set_fields($fields);
    if($this->validation->run() == FALSE)
    {
        $this->load->view('your_search_view');
    }
    else{
        // your data is clean here, so do what you want
        $fname = $this->validation->fname; // this is how you access validated data
        $this->load->view('search_results_view');
    }
?&gt;
This basic structure will allow you to clean your data and then perform the operations as necessary. The user guide outlines this well.

Remember, you can always look at the CI code too. Its not the Windows API!


Messages In This Thread
How to pass multiple values from view->controller->model - by El Forum - 08-07-2008, 01:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB