GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-field-hidden.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file class-gravityview-field-hidden.php
4  * @package GravityView
5  * @subpackage includes\fields
6  */
7 
9 
10  var $name = 'hidden';
11 
12  var $is_searchable = true;
13 
14  var $search_operators = array( 'contains', 'is', 'isnot', 'starts_with', 'ends_with' );
15 
16  var $_gf_field_class_name = 'GF_Field_Hidden';
17 
18  var $group = 'standard';
19 
20  var $icon = 'dashicons-hidden';
21 
22  public function __construct() {
23  $this->label = esc_html__( 'Hidden', 'gk-gravityview' );
24 
25  $this->edit_entry_add_hooks();
26 
27  parent::__construct();
28  }
29 
30  /**
31  * Add Edit Entry hooks
32  *
33  * @since 1.17
34  *
35  * @return void
36  */
37  private function edit_entry_add_hooks() {
38  add_filter( 'gravityview/edit_entry/form_fields', array( $this, 'edit_entry_fix_hidden_fields' ) );
39  }
40 
41  /**
42  * Convert Hidden fields to be Text fields in Edit Entry
43  *
44  * @since 1.9.2
45  * @since 1.17 Moved to GravityView_Field_Hidden class
46  *
47  * @param GF_Field[] $fields Array of fields to be shown on the Edit Entry screen
48  *
49  * @return GF_Field[] Array of fields, with any hidden fields replaced with text fields
50  */
51  function edit_entry_fix_hidden_fields( $fields ) {
52 
53  /** @type GF_Field $field */
54  foreach( $fields as &$field ) {
55 
56  if ( 'hidden' === $field->type ) {
57 
58  /**
59  * @filter `gravityview/edit_entry/reveal_hidden_field` Convert Hidden fields into Text fields on Edit Entry
60  * @since 1.22.6
61  * @since 2.7 Changed default value to `false` from `true`
62  * @param bool $reveal_hidden_field True: Convert the hidden field to text; False: Leave hidden
63  * @param GF_Field_Hidden $field The field in question
64  */
65  $reveal_hidden_field = apply_filters( 'gravityview/edit_entry/reveal_hidden_field', false, $field );
66 
67  if( ! $reveal_hidden_field ) {
68  continue;
69  }
70 
71  // Replace GF_Field_Hidden with GF_Field_Text, copying all the data from $field
72  $field = new GF_Field_Text( $field );
73 
74  // Everything is copied from $field, so we need to manually set the type
75  $field->type = 'text';
76  }
77  }
78 
79  return $fields;
80  }
81 
82 }
83 
Modify field settings by extending this class.
edit_entry_fix_hidden_fields( $fields)
Convert Hidden fields to be Text fields in Edit Entry.
edit_entry_add_hooks()
Add Edit Entry hooks.