Hidden fields and field visibility on Edit Entry
Currently, there are two ways to include hidden fields on your form:
- By using the Hidden field type;
- By changing the field visibility on the "Advanced" tab of each field's settings to either "Hidden" or "Administrative."
GravityView does allow these fields to be visible and/or editable on the Edit Entry page of a View; however, there are some special conditions for that to happen.
See below how that works for each field type:
Hidden field type
If the form has a Hidden Field, the Hidden field will only show up when using the gravityview/edit_entry/render_hidden_field
filter (see code below). It doesn't matter if you manually added this field to the Edit Entry tab, its visibility is determined by the filter.
Field with visibility settings
Visibility settings are found in each field's "Advanced" tab when editing a form in Gravity Forms. You can set the visibility for each type of field in Gravity Forms.
Fields with "Hidden" visibility
These fields will only appear on the Edit Entry page if they have been manually added to the Edit Entry tab on the View editor:
Fields with "Administrative" visibility
These fields will only appear when manually added to the Edit Entry tab or when the Edit Entry tab is empty. However, they are only visible to users within the Administrator role.
For developers: Filters to modify this behavior
These filters only work for Hidden fields. They don't work on fields with visibility set to Hidden or Administrative.
To make Hidden fields visible and editable in Edit Entry:
// Converts `<input type="hidden">` to `<input type="text">`
add_filter( 'gravityview/edit_entry/reveal_hidden_field', '__return_true' );
To prevent Hidden fields from being output on the Edit Entry form HTML, add the following filter:
// Prevent hidden fields from being output in HTML at all
add_filter( 'gravityview/edit_entry/render_hidden_field', '__return_false' );
Note: you can also modify fields displayed in Edit Entry by using the gravityview/edit_entry/form_fields
filter.
Read here how to add these code samples to your website: Where to put code samples.
A timeline of changes regarding rendering Hidden Field fields in Edit Entry
When Edit Entry is not configured, all form fields show by default. The way GravityView has handled Hidden Field fields has changed over time.
Before Version 2.5 of GravityView, when Hidden Field fields were converted to text inputs, they were visible and editable.
To allow modifying this behavior, the gravityview/edit_entry/reveal_hidden_field
filter was added in 1.22.6. The filter could prevent Edit Entry from converting <input type="hidden">
to <input type="text">
. If the filter returned false, the Hidden Field input would still be rendered in HTML, but would not be visible.
With Version 2.5 in December 2019, GravityView changed how Hidden Fields behaved when Edit Entry was not configured: Hidden Field fields would no longer be rendered in the form's HTML. The input value would no longer be visible in the webpage code, and the Hidden Field value would no longer be editable.
In Version 2.7 in February 2020, GravityView added the gravityview/edit_entry/render_hidden_field
filter to control whether the Hidden fields are included in the HTML output or not. The default is set to true
: render the input, but do not make it visible.
By using the gravityview/edit_entry/render_hidden_field
and gravityview/edit_entry/reveal_hidden_field
filters, you control how Hidden Field fields are displayed in Edit Entry.