Hello all,
I'm having a head-banging issue. I'm using the following docs on the site:
Using the Gform validation hook
Gform Validation
and I'm running into an issue. Maybe I need another set of eyes or something - because the issue seems like it should be *so simple* to fix, but for the life of me, I can't get it to work. My filter looks like so:
add_filter('gform_validation_1', 'validate_min_group');
function validate_min_group($validation_result) {
$form = $validation_result["form"];
foreach($form['fields'] as &$field) {
if(strpos($field['cssClass'], 'validate-min') === false) continue;
$field_value = rgpost("input_{$field['id']}"); // retrieve the value
if($field_value < '15') { //if the value is less than 15
$validation_result['is_valid'] = false;
$field['failed_validation'] = true;
$field['validation_message'] = 'A minimum of 15 tickets is required for group pricing.';
}
}
$validation_result['form'] = $form;
return $validation_result;
}
However, no matter what I do, it's absolute: either it ALWAYS returns false, or it ALWAYS returns true.
It would help if I could print_r() or var_dump the values as they pass, but when I do that, it returns nothing. (for example, print_r($field_value);
= doesn't come back at all.) But it just makes no sense at all to me.
I simply want to check if the field value is less than 15. if it is, i want it to return my error message. but like I said, for the life of me, it's absolute. It wither ALWAYS returns an error, or it NEVER does.
Can anyone see what I'm doing wrong here?