[eluser]Randell Benavidez[/eluser]
[quote author="xwero" date="1234275602"]the validation library assumes you only need one parameter, so everything between the square brackets is the parameter value.
Instead of code you better use a comma seperated list callback__required_if_field[type,2], then you can explode it and do the check
Code:
function _required_if_field($str,$param)
{
$temp = explode(',',$param);
if($_POST[$temp[0]] == $temp[1] && empty($str))
{
return false;
}
return true;
}
[/quote]
This is somewhat wrong. You're supposed to have only one parameter for the callback. So if you call
Code:
callback__required_if_field[type, 2]
, your function declaration should only have one parameter like
Code:
function _required_if_field($param)
.
should then be exploded to contain 'type' and '2'. Note that 'type' and '2' are values and not variables.