GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-field-post-custom-field.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file class-gravityview-field-post-custom-field.php
4  * @package GravityView
5  * @subpackage includes\fields
6  */
7 
9 
10  var $name = 'post_custom_field';
11 
12  var $is_searchable = true;
13 
14  /**
15  * @var array $search_operators Custom fields are text, but can be any format (including JSON)
16  */
17  var $search_operators = array( 'contains', 'is', 'isnot' );
18 
19  /**
20  * @see GF_Field_Post_Custom_Field
21  */
22  var $_gf_field_class_name = 'GF_Field_Post_Custom_Field';
23 
24  var $group = 'post';
25 
26  var $icon = 'dashicons-admin-generic';
27 
28  public function __construct() {
29  $this->label = esc_html__( 'Post Custom Field', 'gk-gravityview' );
30  parent::__construct();
31 
32  $this->add_hooks();
33  }
34 
35  /**
36  * Add hooks for the field
37  *
38  * @since 1.17
39  *
40  * @return void
41  */
42  private function add_hooks() {
43  add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 );
44  }
45 
46  /**
47  * Fix "List" Field Type pre-population of content in Edit Entry mode
48  *
49  * @since 1.17
50  *
51  * @param mixed $field_value field value used to populate the input
52  * @param GF_Field $field Gravity Forms field object
53  *
54  * @return mixed If a List input for Custom Field, returns JSON-decoded value. Otherwise, original value.
55  */
57 
58  if( 'list' === $field->inputType ) {
59  $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value;
60 
61  if ( ! is_array( $field_value ) ) {
62  gravityview()->log->error( '"List" Custom Field value not an array or string.', array( 'data' => compact( 'field_value', 'field' ) ) );
63  }
64  }
65 
66  return $field_value;
67  }
68 
69 }
70 
Modify field settings by extending this class.
new GravityView_Field_Post_Custom_Field
$search_operators
$icon
add_hooks()
Add hooks for the field.
$is_searchable
$_gf_field_class_name
__construct()
gravityview()
The main GravityView wrapper function.
edit_entry_field_value( $field_value, $field)
Fix "List" Field Type pre-population of content in Edit Entry mode.
$name
$group
$field_value
Definition: checkbox.php:24