GravityView  1.19.4
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 $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains');
13 
14  var $_gf_field_class_name = 'GF_Field_Checkbox';
15 
16  var $group = 'standard';
17 
18  public function __construct() {
19  $this->label = esc_html__( 'Checkbox', 'gravityview' );
20  parent::__construct();
21  }
22 
23  /**
24  * Add `choice_display` setting to the field
25  *
26  * @param array $field_options
27  * @param string $template_id
28  * @param string $field_id
29  * @param string $context
30  * @param string $input_type
31  *
32  * @since 1.17
33  *
34  * @return array
35  */
36  function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
37 
38  // Set the $_field_id var
39  $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type );
40 
41  // It's not the parent field; it's an input
42  if( floor( $field_id ) !== floatval( $field_id ) ) {
43 
44  if( $this->is_choice_value_enabled() ) {
45 
46  $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' );
47  $default = 'value';
48  $choices = array(
49  'tick' => __( 'A check mark, if the input is checked', 'gravityview' ),
50  'value' => __( 'Value of the input', 'gravityview' ),
51  'label' => __( 'Label of the input', 'gravityview' ),
52  );
53  } else {
54  $desc = '';
55  $default = 'tick';
56  $choices = array(
57  'tick' => __( 'A check mark, if the input is checked', 'gravityview' ),
58  'label' => __( 'Label of the input', 'gravityview' ),
59  );
60  }
61 
62  $field_options['choice_display'] = array(
63  'type' => 'radio',
64  'class' => 'vertical',
65  'label' => __( 'What should be displayed:', 'gravityview' ),
66  'value' => $default,
67  'desc' => $desc,
68  'choices' => $choices,
69  );
70  }
71 
72  return $field_options;
73  }
74 }
75 
Modify field settings by extending this class.
field_options($field_options, $template_id, $field_id, $context, $input_type)
Add choice_display setting to the field.
is_choice_value_enabled()
Check whether the enableChoiceValue flag is set for a GF field.
$field_id
Definition: time.php:17