form validation callbacks: can you pass parameters along? |
[eluser]stef25[/eluser]
is it possible somehow to pass a parameter to a callback function? im using a form_validation.php file and id like to make the 'label' key a variable. i have lots of dropdowns but they all have different values and purposes. sometimes its a type of car, sometimes its a list of countries etc. but always required. im using a callback to make sure that a value is selected but id like to pass 'car' or 'country' to the error message. if its not possible i have to write a validation function for each of those. hope this makes sense ![]() thanks
[eluser]skunkbad[/eluser]
In this post: http://ellislab.com/forums/viewthread/125515/#620714 I shared a solution that might work for you.
[eluser]stef25[/eluser]
where do you set the value of %s? dont see it, but it looks like what i need. thanks alot!
[eluser]augustowloch[/eluser]
[quote author="stef25" date="1251320898"]where do you set the value of %s? dont see it, but it looks like what i need. thanks alot![/quote] %s is automatically filled by the framework, replacing it with the field description!
[eluser]skunkbad[/eluser]
[quote author="augustowloch" date="1253911750"][quote author="stef25" date="1251320898"]where do you set the value of %s? dont see it, but it looks like what i need. thanks alot![/quote] You set the value of %s in the validation rule. I believe it is the second parameter. See the docs.
[eluser]krif[/eluser]
See here: http://ellislab.com/forums/viewthread/121221/ In short, yes you can. e.g. callback_mycallback[string] |
Welcome Guest, Not a member yet? Register Sign In |