Welcome Guest, Not a member yet? Register   Sign In
How to set rules for a form, if the action is on another controller?
#1

[eluser]victorche[/eluser]
It is a simple question, but really with no answer for me.
I have a search form on my index page. With only one input field, with name="keyword".
I also have action="/search" in my form.
So after submit, the results are shown thanks to the search controller.
So far, so good...
But I can not set the rules for the search field. In my case... I require a min lenght of 3 symbols.
Anyway, check this code:
Code:
if ($this->input->post('search'))
        {
            $this->form_validation->set_rules('keyword', 'keyword', 'trim|required|min_length[4]|xss_clean');

            if ($this->form_validation->run() == TRUE)
            {
                echo "We have a submit!!!";
            }
        }
No matter if this is in the index or search controller, it just does not work Sad
In the same time, if I do in the search controller this:
Code:
echo htmlspecialchars($this->input->post('keyword'), ENT_QUOTES, 'UTF-8');
I can see the search keywords, submitted by the form.
Please, note that I am not sending those keywords through the url like:
Quote:example.com/search/keyword_goes_here
But anyway I can see the keywords in the search controller.

Any ideas, please?
#2

[eluser]ladooboy[/eluser]
Can you post the html form as well




Theme © iAndrew 2016 - Forum software by © MyBB