How to create a set of fields dynamically on page load?

Hi there @hiranthi not hijack this, but I’ve gone down that path and fields created in gform_pre_render doesn’t save or seem to send the new fields to the next steps.

I have a similar requirement, except that I’m basing the created fields off of WordPress data. I’ve added a test field but it doesn’t get added to the fields in the {all_fields} placeholder notifications or to the database.

Am I missing a step?

A simple test output the field, but nothing gets saved:

add_filter( 'gform_pre_render_1', 'fg_add_product_fields' );

function fg_add_product_fields( $form ){
	$props = array( 
		'id' => 123,
		'label' => 'My Field Label',
		'type' => 'text'
	);
	$field = GF_Fields::create( $props );
	array_push( $form['fields'], $field );
	return $form;
}