So I solved this, but there seems to be something wrong with Gravity Forms that I am working around when I customized the input fields.
I added a JS file via the gform_post_paging hook that went into the hidden fields and added a checked attribute.
// Adds Checked attribute to hidden fields on page 2 of form
add_action( 'gform_post_paging', 'wps_gform_add_checked' );
function wps_gform_add_checked( $form ) {
// Enqueue script only on the proper form
if ( 5 == $form['id'] && ! is_admin() ) {
wp_enqueue_script( 'wps_gf_checked', plugins_url( 'js/checked.js', __FILE__ ), array( 'jquery' ), '1.0' );
$args = array(
'input_5' => $_POST['input_5'],
'input_8' => $_POST['input_8'],
);
wp_localize_script( 'wps_gf_checked', 'wps_gf_checked', $args );
}
}
The JS file:
jQuery(function($) {
$('#gform_page_5_1 #input_5_5 input').each(function() {
if(wps_gf_checked.input_5 == $(this).val())
$(this).attr('checked','checked')
});
$('#gform_page_5_1 #input_5_8 input').each(function() {
if(wps_gf_checked.input_8 == $(this).val())
$(this).attr('checked','checked')
});
});
However, it seems that GF should have stored the $_POST correctly. Because on page 2, here is the $_POST var:
Array ( [input_5] => design02 [input_8] => background02 [input_1] => [input_6] => [input_2_3] => [input_2_6] => [input_3_1] => [input_3_2] => [input_3_3] => [input_3_4] => [input_3_5] => [input_3_6] => [input_4] => [input_11] => [is_submit_5] => 1 [gform_submit] => 5 [gform_unique_id] => 4fc6b84796a84 [state_5] => {DELETED by wpsmith} = [gform_target_page_number_5] => 2 [gform_source_page_number_5] => 1 [gform_field_values] => )
So, $_POST obviously sees that input_5 and input_8 are saved correctly, even with the same nomenclature as GF. So I do not understand why GF didn't automatically check these as appropriate. Thoughts?
Posted 12 years ago on Thursday May 31, 2012 |
Permalink