[eluser]benster[/eluser]
Hi,
Is there a way I can create a form validation callback_function that can be used by different forms using different form inputs?
For example, I would like a function that compares two times that are form inputs. So I need some way to call the callback function with both form values.
I would then like to be able to use the same function for other forms, again, passing in the two form values.
Typically I use something like:
Code:
$this->form_validation->set_rules('overrideTimeStart', 'Start Time', 'trim|required|xss_clean|callback_validtime');
However this only alows me to pass in the overrideTimeStart. I can then get the overrideTimeEnd (the other form value) by gettin the form input using:
Code:
$this->input->post('overrideTimeEnd');
So the 2 issues with this I have are:
1) Im not sure that using $this->input->post('overrideTimeEnd'); validates that form input e.g. XSS etc as set in my form validation rules before it gets to my callback function.
2) I cannot reuse that function for another form because I have hard coded
Code:
$this->input->post('overrideTimeEnd');
in to the function for the second form input.
Can anyone advise on est practice for writing callback functions to be used by different forms?
Best regards, Ben.