Welcome Guest, Not a member yet? Register   Sign In
form validation: limiting a field to a set of values.
#1

[eluser]srisa[/eluser]
Hello,

Say I have two radio buttons with values 'M' and 'F'. Can I set a validation rule for that field such that it takes either 'M' or 'F'?

Thank you.
#2

[eluser]davidbehler[/eluser]
As far as I know there is no validation rule to do what you want to do.
There are 2 things you could do: Use a callback function or extend the form validation library and add your own rule that checks a field for certain values.

Have a look at the user guide on how to use callback functions or extend libraries.
#3

[eluser]srisa[/eluser]
Thank you.
I was thinking about the callback function, but wanted to make sure that the validation rule I am looking for doesn't exist.
#4

[eluser]srisa[/eluser]
I have put the callback functions in the controller. If I declare them as private, an error is being thrown. I had to declare them as public. Is that okay?
What will be the naming convention if I want to define the callback functions in a helper or a library? Within the controller I can do it as 'callback_my_func_name', where 'callback_' seems to be the required prefix.




Theme © iAndrew 2016 - Forum software by © MyBB