Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - add_filter('gform_pre_render_7', 'gform_populate_selected_options');
 - add_filter('gform_pre_submission_filter_7', 'gform_populate_selected_options');
 - function gform_populate_selected_options($form) {
 - $field_id = 8; // update to the ID of your options field
 - $option_price = '305.00'; // update to the price of your options
 - $no_options_message = 'We\'re sorry, there were no options specified.'; // message displayed when no options were selected
 - /* you should not need to edit below this line */
 - foreach($form['fields'] as &$field) {
 - if($field['id'] != $field_id)
 - continue;
 - $selected_options = explode(',', rgget($field['inputName']));
 - $choices = array();
 - $inputs = array();
 - if(!rgget($field['inputName'])) {
 - $field['description'] = $no_options_message;
 - } else {
 - $input_id = 1;
 - foreach($selected_options as $selected_option) {
 - $choices[] = array('text' => $selected_option, 'value' => $selected_option, 'price' => '305.00', 'isSelected' => true);
 - if($input_id % 10 == 0)
 - $input_id++;
 - $inputs[] = array('id' => "{$field['id']}.{$input_id}", 'label' => $selected_option, 'name' => '');
 - $input_id++;
 - }
 - }
 - $field['choices'] = $choices;
 - $field['inputs'] = $inputs;
 - $field['enableChoiceValue'] = false;
 - }
 - return $form;}
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment