PDF for GravityView Hooks – gfpdf_gv_show_label
Description
Show or hide the field labels in a PDF by returning true or false. It runs for every layout (Table, List, Map, DIY and Layout Builder) and for both the Single Entry and Multiple Entries PDFs. Two aliases target a single View or layout:
Alias
gfpdf_gv_show_label_{$view_id}: replace{$view_id}with a View ID.gfpdf_gv_show_label_{$layout}: valid values for{$layout}aretable,list,map,diyandlayout_builder.
Since 2.0, each PDF tab in the View editor has a Show Labels? setting, which is the easiest way to hide the labels on one View. The setting is passed in as $show_label, then gfpdf_gv_show_label, gfpdf_gv_show_label_{$view_id} and gfpdf_gv_show_label_{$layout} run in that order. A filter always overrides the setting, so code written for 1.x keeps working.
Version
This hook was introduced in PDF for GravityView 0.2. The {$view_id} and {$layout} aliases were added in 0.6.
In 2.0 it also runs for the Multiple Entries PDF and the DIY and Layout Builder layouts, and its starting value comes from the Show Labels? setting.
Arguments
The following arguments are passed to functions that use this hook:
$show_label | bool
- Whether to show the field labels.
- The default value is the Show Labels? setting from the View's Single Entry PDF or Multiple Entries PDF tab, which is
trueunless unticked.
$view | \GV\View
- The View the PDF is being generated for.
$view_entry | \GV\Entry or \GV\Entry_Collection
- A
\GV\Entryfor a Single Entry PDF. - A
\GV\Entry_Collectionfor a Multiple Entries PDF.
$layout | string
- The View's layout.
- Valid values include:
tablelistmapdiylayout_builder - DataTables Views use
table.
Usage
Hide the field labels in all PDFs:
add_filter( 'gfpdf_gv_show_label', '__return_false' );
Hide the field labels in PDFs for Table layout Views:
add_filter( 'gfpdf_gv_show_label_table', '__return_false' );
Source Code
This filter is located in src/Pdf/Layout/ShowLabel.php of the PDF for GravityView extension, and is run by every template in the /src/Pdf/Templates/ directory.