I want to pass one step field data to another step in multistep form

Hello I have a multistep gravity form. In first step i’m using state field and 2nd step based on user selection i want to pass that state name in next field. this is my form link OTP Verification form page – Peachtree Debt Relief Company

Hi Ayesha. You can use the gform_pre_render filter to do that. This example shows how to carry data from one page to the next in a multi-page form:

Let us know if you have any other questions.

But this code is for uploading image in next step.
I want to show state name in html which is selected in previous step. I’m using select field for the states field.

Hello Ayesha!

Try the following code snippet. Be sure to replace the IDs with your actual ones.



// Replace 49 below with your actual form ID.
add_filter( 'gform_pre_render_49', 'populate_html' );

function populate_html( $form ) {
	if ( empty( $form['id'] ) ) {
		return $form;
	}
	$html_field_id  = 4; //Replace 4 with your actual HTML field ID.
	$state_field_id = 1; //Replace 1 with your actual state field ID.

	//this is a 2-page form with the data from page one being displayed in an html field on page 2
	$current_page = GFFormDisplay::get_current_page( $form['id'] );

	if ( $current_page == 2 ) {

		//Get the value of the state field.
		foreach ( $form['fields'] as $field ) {
			if ( $field->id == $state_field_id ) {
				$state = rgpost( 'input_' . $field->id );
				$html_content = $field->label . ': ' . $state;
				break;
			}
		}

		//Populate HTML field.
		foreach( $form['fields'] as &$field ) {
			//get html field
			if ( $field->id == $html_field_id ) {
				//set the field content to the html
				$field->content = $html_content;
			}
		}
	}
	//return altered form so changes are displayed
	return $form;
}
1 Like

Thank you
Let me try then I’ll get back to you:)

1 Like

Hello
I tried this code is not working

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.