How do we return product quantity in gform_hooks ?
How do we return product quantity in gform_hooks ?
Can you give me more information on what you are trying to do? I don't understand.
I'm triying to return the value for the product qty.
I need to validate qty field. It should be trivial no?
Check this out: http://projets.collectiv.ca/northsec-2013/
Something like this maybe ...
But in gform_field_validation hook.
Have you tried the following?
http://www.gravityhelp.com/documentation/page/Gform_field_validation
I would like to test if my list field rows == product quantity in the second step.
Since the quantity field is in the step 1, it is not validated on step 2
The quantity would be use to populate the field list with the required rows.
I would really appreciate some help on this one.
All I need to do is to populate a list field with a qty collected in the first step.
Here is the code:
// Populate list with selected quantity
add_filter("gform_pre_render_1", "pre_populate_row_list");
function pre_populate_row_list($form){
$field_id = 15; // Member list
$product_qty = rgpost('input_30');
$list = rgpost('input_15');
$current_page = GFFormDisplay::get_current_page($form["id"]);
//if($current_page == 2){
foreach($form['fields'] as &$field){
if($field['id'] != $field_id)
continue;
// Dynamic Population doesn't work :\
$array = array_fill(0, $product_qty ,'');
$field['choices'] = array_fill(0, 2, $array);
//$field['label'] = implode(',',$field['choices']);
}
//}
return $form;
}
So I don't think you can use pre_render to take something from one section of a form and populate another. Because when pre_render has run, no one has typed anything in yet.
Have you looked at this:
http://www.gravityhelp.com/documentation/page/Gform_post_paging
Thanks. Thats how I did it finaly.
add_filter("gform_field_validation_1_15", "validate_list_field", 10, 4);
function validate_list_field($result, $value, $form, $field){
$product_qty = rgpost('input_33');
// Test if equal quantity
if( count($current_emails) != $product_qty ){
$result["is_valid"] = false;
$result["message"] .= sprintf(__('<br/>Vous devez inscrire (%d) personnes dans votre équipe.','nsec'), $product_qty);
}
// always return result
return $result;
}
Thank you for sharing your code.