Hi guys,
I've been searching through the forum posts and small snippets here and there somewhat guide me to my goal. However, I'm still not there. I hope (one of) you can give me the remaining piece of info to complete my task.
Situation
People filling out my form have to select a radiobutton in order to choose "Yes" or "No". The value selected is translated by using "show values" to 1 (for yes) or 0 (for no). I need this translation, because our automated CSV-import can only interpret a boolean value.
So far so good. The challenge starts when I want to represent the choice in a resulting (PDF) document in a nice "human" way.
Proposed solution
I've added a second field, which is hidden to the public. Using a "hook" I've included a piece of code to the functions.php;
add_filter('gform_field_value_newsletter', 'my_custom_population_function');
function my_custom_population_function($value){
global $post;
$newsletter = get_post_meta($post->ID,'Receive_newsletter');
$value='would like';
if($newsletter == '0')
{
$value='would not like';
}
return $newsletter;
}
The idea is to take the resulting fieldcode of newsletter and integrate it into a sentence, like;
"I would like to receive a newsletter", or
"I would not like to receive a newsletter"
Discussion
My approach is faulty. I'm trying to set a value based upon a post value, that hasn't been posted yet (right?). Processing of this value can easily take place after post. However, I don't know where to put the code and what code to include.
Hope my question makes sense? I really like GF and the possibilities seem endless. Unfortunately I sometimes get lost searching for the proper way to proceed.
Thanks,
Nick