Welcome Guest, Not a member yet? Register   Sign In
Problem with form validation and view data
#1

[eluser]tatacarrera[/eluser]
Well this is my first post in this forum, so here it goes:

I have something like this

Code:
function user() {
        $this->load->model('category');
        $this->load->model('post');

        $this->load->library('form_validation');

        $this->form_validation->set_rules('user', 'name', 'required|xss_clean');
        $this->form_validation->set_rules('post', 'post', 'required|max_length[200]');

        if ($this->form_validation->run() == FALSE) {
            $data['categories'] = $this->category->getCategoriesArray();
            $data['posts'] = $this->post->getPostArray();
            $this->load->view('creation_form', $data);
        } else {
            /*some other code*/
        }
    }

the two functions getCategoriesArray and getPostArray returns arrays for using the 'form_dropdown()' function in the 'creation_form' view, at the first page load, everything is fine, but when I input some bad data, the 'creation_form' is intended for reload but the data passed to the view dissapears. This result into a 'form_dropdown' error because the system can't locate the variables $categories and $posts

It's not posible to pass some variables twice into a form?
#2

[eluser]tatacarrera[/eluser]
i had a problem with the form action. I was redirecting the action to another view that was equal to the other.
#3

[eluser]vikascoollives[/eluser]
Can you give the sample code of view where you have used those variables so that i get how you are using the variables in the view.




Theme © iAndrew 2016 - Forum software by © MyBB