How to randomize the order of values in dropdown field?

I can’t figure out how to simply randomize the order of values in a dropdown field.

The usecase is a lead submission form where we ask “how did you hear about us?” We don’t want to bias the results by showing the options in the same order each time - rather we want it to be random on each form load.

For example, if the options are:

1.“Google Search”
2. “Heard from a friend”
3. “Other”

…we would want them to be in random order each time the form is loaded or ideally just for each unique visitor.

Hi Matt. Randomizing the order of the choices presented in a drop down field is not supported in Gravity Forms. If you would like to suggest that for inclusion in the future, I recommend adding that to our product roadmap. Click the blue :heavy_plus_sign: in the lower left on this page to add a note for our product team:

Thank you.

You could use the gform_pre_render filter in the theme functions.php file or a custom functions plugin to shuffle the array of choices on form display. This example applies to form id 681 and field id 1:

add_filter( 'gform_pre_render_681', function ( $form ) {
	$field_id = 1;
	$field    = GFAPI::get_field( $form, $field_id );
	if ( $field instanceof GF_Field_Select ) {
		shuffle( $field->choices );
	}

	return $form;
} );
1 Like

Hey Matt, great question!

We had the same need at Gravity Wiz for an internal form and realized there wasn’t an off-the-shelf solution. So, we dreamt up and created Gravity Forms Randomizer. :smiley:

1 Like