Wordpress Gravity Forms: Pass dropdown's value to 2nd page's dropdown -
i have wordpress gravity form.
on 1st page of form, have dropdown box dynamically populated. no problems here.
now, on 2nd page of same form, have dropdown need dynamically populate too, based on selected option 1st dropdown.
is possible, , if so, not complicated do?
here's example i'm populating drop down on page 2 post meta based on post selected drop down on page 1:
add_filter( 'gform_pre_render_918', 'populate_post_meta' ); add_filter( 'gform_pre_validation_918', 'populate_post_meta' ); add_filter( 'gform_pre_submission_filter_918', 'populate_post_meta' ); add_filter( 'gform_admin_pre_render_918', 'populate_post_meta' ); function populate_post_meta( $form ) { $field_id = 3; $post_field_id = 1; foreach ( $form['fields'] &$field ) { if ( $field->id != $field_id ) { continue; } // can add additional parameters here alter posts retrieved // more info: [http://codex.wordpress.org/template_tags/get_posts](http://codex.wordpress.org/template_tags/get_posts) $post_id = rgpost( "input_{$post_field_id}" ); $post_meta = get_post_custom( $post_id ); $choices = array(); foreach ( $post_meta $value ) { $choices[] = array( 'text' => $value[0], 'value' => $value[0] ); } // update 'select post' whatever you'd instructive option $field->placeholder = 'select value'; $field->choices = $choices; } return $form; }
full code here: http://pastie.org/private/okftjhfkmzgqkwhneixmg
Comments
Post a Comment