GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-field-checkbox.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file class-gravityview-field-checkbox.php
4  * @package GravityView
5  * @subpackage includes\fields
6  */
7 
9 
10  var $name = 'checkbox';
11 
12  var $is_searchable = true;
13 
14  /**
15  * @see GFCommon::get_field_filter_settings Gravity Forms suggests checkboxes should just be "is"
16  * @var array
17  */
18  var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' );
19 
20  var $_gf_field_class_name = 'GF_Field_Checkbox';
21 
22  var $group = 'standard';
23 
24  var $icon = 'dashicons-yes';
25 
26  public function __construct() {
27  $this->label = esc_html__( 'Checkbox', 'gk-gravityview' );
28  parent::__construct();
29  }
30 
31  /**
32  * Add `choice_display` setting to the field
33  *
34  * @param array $field_options
35  * @param string $template_id
36  * @param string $field_id
37  * @param string $context
38  * @param string $input_type
39  *
40  * @since 1.17
41  *
42  * @return array
43  */
44  public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
45 
46  // Set the $_field_id var
47  $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id );
48 
49  // It's the parent field, not an input
50  if( floor( $field_id ) === floatval( $field_id ) ) {
51  return $field_options;
52  }
53 
54  if( $this->is_choice_value_enabled() ) {
55 
56  $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gk-gravityview' );
57  $default = 'value';
58  $choices = array(
59  'tick' => __( 'A check mark, if the input is checked', 'gk-gravityview' ),
60  'value' => __( 'Value of the input', 'gk-gravityview' ),
61  'label' => __( 'Label of the input', 'gk-gravityview' ),
62  );
63  } else {
64  $desc = '';
65  $default = 'tick';
66  $choices = array(
67  'tick' => __( 'A check mark, if the input is checked', 'gk-gravityview' ),
68  'label' => __( 'Label of the input', 'gk-gravityview' ),
69  );
70  }
71 
72  $field_options['choice_display'] = array(
73  'type' => 'radio',
74  'class' => 'vertical',
75  'label' => __( 'What should be displayed:', 'gk-gravityview' ),
76  'value' => $default,
77  'desc' => $desc,
78  'choices' => $choices,
79  'group' => 'display',
80  'priority' => 100,
81  );
82 
83  return $field_options;
84  }
85 }
86 
Modify field settings by extending this class.
field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id)
Add choice_display setting to the field.
is_choice_value_enabled()
Check whether the enableChoiceValue flag is set for a GF field.
if(empty( $created_by)) $form_id
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
Definition: time.php:22