Created
June 30, 2014 18:25
-
-
Save spivurno/4fab899db8b342f67378 to your computer and use it in GitHub Desktop.
Get the selected survey choice based on entry value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the selected survey choice based on entry value. | |
*/ | |
function gw_survey_get_selected_choice( $entry, $field_id ) { | |
$form = GFAPI::get_form( $entry['form_id'] ); | |
$key = rgar( $entry, $field_id ); | |
foreach( $form['fields'] as $field ) { | |
if( $field['id'] != $field_id ) | |
continue; | |
foreach( $field['choices'] as $choice ) { | |
if( $choice['value'] == $key ) | |
return $choice; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment