GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-radio-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default radio field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field_id = $gravityview->field->ID;
15 $field = $gravityview->field->field;
16 $display_value = $gravityview->display_value;
17 $entry = $gravityview->entry->as_entry();
18 $field_settings = $gravityview->field->as_configuration();
19 
20 $display_type = isset( $field_settings['choice_display'] ) ? $field_settings['choice_display'] : 'value';
21 
22 $output = '';
23 
24 if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
25 
26  if ( 'value' === $display_type ) {
27  // For the complete field value
29  } else {
30  $output = RGFormsModel::get_choice_text( $field, $display_value );
31  }
32 } else {
33  // For part of the field value
34  $entry_keys = array_keys( $entry );
35  foreach( $entry_keys as $input_key ) {
36  if( is_numeric( $input_key ) && floatval( $input_key ) === floatval( $field_id ) ) {
37  if( in_array( $field['type'], array( 'radio', 'checkbox' ) ) && !empty( $entry[ $input_key ] ) ) {
38  $output = apply_filters( 'gravityview_field_tick', '<span class="dashicons dashicons-yes"></span>', $entry, $field, $gravityview );
39  } else {
40  $output = $entry[ $input_key ];
41  }
42  }
43  }
44 }
45 
46 echo $output;
$display_value
$display_type
if(! isset( $gravityview)||empty( $gravityview->template)) $field_id
The default radio field output template.
gravityview()
The main GravityView wrapper function.
$field_settings