Skip to content

Instantly share code, notes, and snippets.

@tylerdigital
Created August 23, 2012 20:31
Show Gist options
  • Save tylerdigital/3441310 to your computer and use it in GitHub Desktop.
Save tylerdigital/3441310 to your computer and use it in GitHub Desktop.
Create a Gravity Form dropdown with custom array values
add_filter('gform_pre_render', 'tdgf_favorite_food');
function tdgf_favorite_food($form) {
if(empty($form['fields'])) return;
foreach ($form['fields'] as $key => &$field) {
if($field['cssClass']!='favorite_food' || empty($field['choices'])) continue;
$field['choices'] = array('apples' => 'Apples', 'oranges' => 'Oranges');
}
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment