Skip to content

Instantly share code, notes, and snippets.

@yellowstonebum
Last active September 18, 2018 15:49
Show Gist options
  • Save yellowstonebum/acef5094a6c079a8edbbb454fcf08a29 to your computer and use it in GitHub Desktop.
Save yellowstonebum/acef5094a6c079a8edbbb454fcf08a29 to your computer and use it in GitHub Desktop.
Gravity Forms - Populate Column with Entry Data - Simple
<?php
// The following snippet will populate a List Field's dropdown with another forms entries.
// Direct the snippet to populate the field with "gform_column_input_42_1_4". 42 being the
// field, 1 being the field, and 4 being the column
// BE AWARE - changing the column in the list field will break this snippet
add_filter( 'gform_column_input_42_1_4', 'feature_column', 10, 5 );
function feature_column( $input_info, $field, $column, $value, $form_id ) {
// Input the form ID that you wish to pull from. For me that was field 7
$form_id = 7;
$entries = GFAPI::get_entries( $form_id );
$items = array();
if (is_array($entries))
{
// 114 is the Field ID that I am querying from Form 7.
foreach ($entries as &$entry) $items[] = array("value" => $entry['114'], "text" => $entry['114']);
}
return array( 'type' => 'select', 'choices' => $items );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment