Welcome Guest, Not a member yet? Register   Sign In
Form validation config vs set_rules
#1

[eluser]cideveloper[/eluser]
I have a situation I cant seem to figure out. Here is the situation.

I have a page with checkboxes that submits to another page that I have to enter some data. This second page needs to have the newly entered data validated. I am having a problem with setting the rules on the second page. Here is what I mean

Working Example (Config file rules)
------------------------------
- Page 1 submits checkboxes to page 2
- Page 2 shows no errors
- I fill out information on page 2 which submits to itself. If there is errors they show on the page.

Non Working Example (rules set using set_rules in controller)
---------------------------------------
- Page 1 submits checkboxes to page 2
- Page 2 shows all the validation errors as if nothing was filled in (obviously, I havent even gotten to the page
- It works fine after here but I don't want to see the validation errors the first time I come to the page

Why does it work when setting in config file. I've gone through the form validation library and cant see the problem.

I can post some code if absolutely necessary.

Thanks
#2

[eluser]Aken[/eluser]
I'm thinking maybe the first method isn't working at all. Maybe NO rules are being set in the first case, which would result in no errors.

If you're submitting two different sets of data to the same controller, you should use rule sets to specify which data to compare. So you'd need to have two instances of $this->form_validation->run(), with each run() specifying a rule set. See "Creating Sets of Rules"




Theme © iAndrew 2016 - Forum software by © MyBB