Welcome Guest, Not a member yet? Register   Sign In
How can I use multiple validation forms in one page with seperate objects?
#1

[eluser]Isos[/eluser]
I am using two validations in the same page. one is for submitting a message and one for replies to an existing one. I use toggle to hide and show each.

Now if $this->validation->run() returned false, error_string must appear above each form and will run the toggle.

The problem that I am having is that since both are on the same page, the error appears for both when a validation returned false.

Any tip how can I rename $this->validation to fit each form?

I hope I made it clear.

Thanks
#2

[eluser]Pascal Kriete[/eluser]
Add a hidden field to each form and use something descriptive for it's value.

Then use that to figure out which form to show.
#3

[eluser]Isos[/eluser]
Well, that's what I did for as fast solution. But this is still not the best solution I guess, it's not that secure way cuz the value maybe changed as you know by the user. :/ I want a better solution. Something like when calling a model ie. $this->load->model('default_model','default');

I will see if I can tweak the validation library .. But this will force me to modify the same thing everytime I upgrade Codeigniter! .. Anyway, still open to some better solutions.
#4

[eluser]tonanbarbarian[/eluser]
Do not tweak the validation libray - extend it.
I know I have posted an extension to the validation library which allows you to have multiple forms. It works by allowing you to prefix the rules by the name of the form or model.
Validation and multiple forms
Hopefully this is something like what you are looking for




Theme © iAndrew 2016 - Forum software by © MyBB