GravityView  1.19.4
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  var $_gf_field_class_name = 'GF_Field_Post_Custom_Field';
15 
16  var $group = 'post';
17 
18  public function __construct() {
19  $this->label = esc_html__( 'Post Custom Field', 'gravityview' );
20  parent::__construct();
21 
22  $this->add_hooks();
23  }
24 
25  /**
26  * Add hooks for the field
27  *
28  * @since 1.17
29  *
30  * @return void
31  */
32  private function add_hooks() {
33  add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 );
34  }
35 
36  /**
37  * Fix "List" Field Type pre-population of content in Edit Entry mode
38  *
39  * @since 1.17
40  *
41  * @param mixed $field_value field value used to populate the input
42  * @param GF_Field $field Gravity Forms field object
43  *
44  * @return mixed If a List input for Custom Field, returns JSON-decoded value. Otherwise, original value.
45  */
47 
48  if( 'list' === $field->inputType ) {
49  $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value;
50 
51  if ( ! is_array( $field_value ) ) {
52  do_action( 'gravityview_log_error', __METHOD__ . ': "List" Custom Field value not an array or string.', compact( 'field_value', 'field' ) );
53  }
54  }
55 
56  return $field_value;
57  }
58 
59 }
60 
Modify field settings by extending this class.
new GravityView_Field_Post_Custom_Field
add_hooks()
Add hooks for the field.
$is_searchable
$_gf_field_class_name
__construct()
$name
edit_entry_field_value($field_value, $field)
Fix "List" Field Type pre-population of content in Edit Entry mode.
$group
$field_value
Definition: checkbox.php:24
$field
Definition: gquiz_grade.php:11