Auto populate form fields based on dropdown list option

Hi, so I’ve created a form with the following fields: username(drop down list), name(text field), surname(text field), Username field populates the drop down list options with actual usernames in wordpress using the following code (https://legacy.forums.gravityhelp.com/topic/populate-drop-down-list-with-usernames).

What I’m trying to do is fetch the name and surname of the user selected in the drop down field and dynamically populate the name and surname fields.

Thank you in advance.

That is going to require some customization. You may want post something on our Job Board or look for some help here. I’ll leave it open in case anyone has an idea to share. Thank you.

We (Gravity Wiz) have an early-access plugin available called GF Populate Anything that will handle populating a Drop Down field with a list of users and also populating the Name field with the selected users’s name.

If you’re a Gravity Perks customer, drop us a line via the support form and we’ll be happy to send you a copy of the plugin.

2 Likes

Thank you very much guys, @david let me sit down with my teem to motivate this.

2 Likes

Soo… this is older, but if you are still looking, this is how I solved it for myself:

<?php
 add_filter( 'gform_column_input_{form_id}_{field_id}_{column_number}', 'column_name', 10, 5 );
function column_name( $input_info, $field, $column, $value, $form_id ) {

//Form ID that you are getting the entries from
  $form_id = 45;
  $entries = GFAPI::get_entries( $form_id );
  $items = array();

  if (is_array($entries))
{
    foreach ($entries as &$entry){
//Field ID of the entries you want to pre populate
	$items[] = array("value" => $entry['2'], "text" => $entry['2']);
}
      return array( 'type' => 'select', 'choices' => $items );

}
      die();
}
2 Likes