Skip to main content

GF_Field_Consent

The Consent Field keeps track of exactly what the user consented to. The consent value ("1"), checkbox label and the Form revision ID

are all stored in the entry meta table in separate input values when consent is given.

Since: 2.4 (Class GF_Field_Consent)

Source: includes/fields/class-gf-field-consent.php:15

Details

  • Kind: class
  • Namespace: (global)
  • Extends: GF_Field

Properties

PropertyTypeDescription
$typestringDeclare the field type.
$duplicatableboolWhether there can be more than one of this field type per form.
$repeatableboolWhether the field can be used in a repeater. Consent field is currently not supported in repeaters.
$checked_indicator_urlstringChecked indicator URL.
$checked_indicator_markupstringChecked indicator image markup.
$_supports_state_validationboolIndicates if this field supports state validation.

Methods

MethodDescription
__construct()GF_Field_Consent constructor.
get_form_editor_field_title()Returns the field title.
get_form_editor_field_description()Returns the field's form editor description.
get_form_editor_field_icon()Returns the field's form editor icon.
get_form_editor_button()Returns the field button properties for the form editor. The array contains two elements:
get_form_editor_field_settings()Returns the class names of the settings which should be available on the field in the form editor.
is_conditional_logic_supported()Indicate if this field type can be used when configuring conditional logic rules.
get_field_container_tag()Returns the HTML tag for the field container.
get_field_input()Returns the field inner markup.
get_first_input_id()Returns the input ID to be assigned to the field label for attribute.
get_description()Returns the markup for the field description.
get_aria_describedby()If a field has a description, the aria-describedby attribute for the input field is returned.
is_value_submission_empty()Used when determining if the field has failed required validation.
get_value_save_input()Sanitize and format the value before it is saved to the Entry Object.
get_value_merge_tag()Set the values of consent field inputs in merge tags.
get_value_entry_list()Format the entry value for display on the entries list page.
get_value_entry_detail()Format the entry value for display on the entry detail page and for the {all_fields} merge tag.
get_value_export()Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().
sanitize_settings()Forces settings into expected values while saving the form object.
get_filter_settings()Returns the filter settings for the current field.
get_filter_operators()Returns the filter operators for the current field.
get_filter_values()Returns the filters values setting for the current field.
get_field_description_from_revision()Get consent description from the form revision.
skip_state_validation_if_blank()Indicates if state validation should be skipped if the submitted value is blank.
get_values_for_state_hash()Prepares the value that will be hashed on form display as part of the state.

Method Reference

__construct()

public function __construct( $data=[] )

GF_Field_Consent constructor.

Parameters

NameTypeDefaultDescription
$dataarray[]Data needed when initiate the class.

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:78

get_form_editor_field_title()

public function get_form_editor_field_title()

Returns the field title.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:107

get_form_editor_field_description()

public function get_form_editor_field_description()

Returns the field's form editor description.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field-consent.php:118

get_form_editor_field_icon()

public function get_form_editor_field_icon()

Returns the field's form editor icon.

This could be an icon url or a gform-icon class.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field-consent.php:131

get_form_editor_button()

public function get_form_editor_button()

Returns the field button properties for the form editor. The array contains two elements:

'group' => 'standard_fields' // or 'advanced_fields', 'post_fields', 'pricing_fields' 'text' => 'Button text'

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:144

get_form_editor_field_settings()

public function get_form_editor_field_settings()

Returns the class names of the settings which should be available on the field in the form editor.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:158

is_conditional_logic_supported()

public function is_conditional_logic_supported()

Indicate if this field type can be used when configuring conditional logic rules.

Returns

  • bool

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:180

get_field_container_tag()

public function get_field_container_tag( $form )

Returns the HTML tag for the field container.

Parameters

NameTypeDefaultDescription
$formarrayThe current Form object.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field-consent.php:193

get_field_input()

public function get_field_input( $form, $value=[], $entry=null )

Returns the field inner markup.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.
$valuearray[]The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
$entrynull | arraynullNull or the Entry Object currently being edited.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:214

get_first_input_id()

public function get_first_input_id( $form )

Returns the input ID to be assigned to the field label for attribute.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:274

get_description()

public function get_description( $description, $css_class )

Returns the markup for the field description.

Parameters

NameTypeDefaultDescription
$descriptionstringThe field description.
$css_classstringThe css class to be assigned to the description container.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:290

get_aria_describedby()

public function get_aria_describedby( $extra_ids=[] )

If a field has a description, the aria-describedby attribute for the input field is returned.

This method is specific to the consent field since the consent description has a different ID pattern.

Parameters

NameTypeDefaultDescription
$extra_idsarray | string[]Any extra ids that should be added to the describedby attribute.

Returns

  • string

Since: 2.6.8

Source: includes/fields/class-gf-field-consent.php:312

is_value_submission_empty()

public function is_value_submission_empty( $form_id )

Used when determining if the field has failed required validation.

The consent field has three inputs; only the checkbox is required.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form currently being processed.

Returns

  • bool

Since: 2.7.5

Source: includes/fields/class-gf-field-consent.php:339

get_value_save_input()

public function get_value_save_input( $value, $form, $input_name, $entry_id, $entry, $repeater_index='' )

Sanitize and format the value before it is saved to the Entry Object.

Parameters

NameTypeDefaultDescription
$valuestringThe value to be saved.
$formarrayThe Form object currently being processed.
$input_namestringThe input name used when accessing the $_POST.
$entry_idintThe ID of the entry currently being processed.
$entryarrayThe entry currently being processed.
$repeater_indexstring''The repeater item index if the field is inside a repeater (e.g., '_0', '_1', '_0_1').

Returns

  • array | string — The sanitized and formatted input value to be saved.

Since: 3.0.0

Source: includes/fields/class-gf-field-consent.php:357

get_value_merge_tag()

public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br )

Set the values of consent field inputs in merge tags.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value. Depending on the location the merge tag is being used the following functions may have already been applied to the value: esc_html, nl2br, and urlencode.
$input_idstringThe field or input ID from the merge tag currently being processed.
$entryarrayThe Entry Object currently being processed.
$formarrayThe Form Object currently being processed.
$modifierstringThe merge tag modifier. e.g. value.
$raw_valuestring | arrayThe raw field value from before any formatting was applied to $value.
$url_encodeboolIndicates if the urlencode function may have been applied to the $value.
$esc_htmlboolIndicates if the esc_html function may have been applied to the $value.
$formatstringThe format requested for the location the merge is being used. Possible values: html, text or url.
$nl2brboolIndicates if the nl2br function may have been applied to the $value.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:391

get_value_entry_list()

public function get_value_entry_list( $value, $entry, $field_id, $columns, $form )

Format the entry value for display on the entries list page.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$entryarrayThe Entry Object currently being processed.
$field_idstringThe field or input ID currently being processed.
$columnsarrayThe properties for the columns being displayed on the entry list page.
$formarrayThe Form Object currently being processed.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:422

get_value_entry_detail()

public function get_value_entry_detail( $value, $entry=[], $use_text=false, $format='html', $media='screen' )

Format the entry value for display on the entry detail page and for the {all_fields} merge tag.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$entryarray[]The entry.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstring'html'The format requested for the location the merge is being used. Possible values: html, text or url.
$mediastring'screen'The location where the value will be displayed. Possible values: screen or email.

Returns

  • string

Since:

  • 2.4
  • 2.9.29 (Changed the second parameter $currency (string) to $entry (array).)

Source: includes/fields/class-gf-field-consent.php:449

get_value_export()

public function get_value_export( $entry, $input_id='', $use_text=false, $is_csv=false )

Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().

For CSV export return a string or array.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry currently being processed.
$input_idstring''The field or input ID.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$is_csvbool | falsefalseIs the value going to be used in the .csv entries export.

Returns

  • string | array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:489

sanitize_settings()

public function sanitize_settings()

Forces settings into expected values while saving the form object.

No escaping should be done at this stage to prevent double escaping on output.

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:517

get_filter_settings()

public function get_filter_settings()

Returns the filter settings for the current field.

If overriding to add custom settings call the parent method first to get the default settings.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:531

get_filter_operators()

public function get_filter_operators()

Returns the filter operators for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:554

get_filter_values()

public function get_filter_values()

Returns the filters values setting for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:567

get_field_description_from_revision()

public function get_field_description_from_revision( $revision_id )

Get consent description from the form revision.

Parameters

NameTypeDefaultDescription
$revision_idintRevision ID.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-consent.php:587

skip_state_validation_if_blank()

public function skip_state_validation_if_blank( $key )

Indicates if state validation should be skipped if the submitted value is blank.

Input value will be blank when the input is not checked.

Parameters

NameTypeDefaultDescription
$key

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field-consent.php:647

get_values_for_state_hash()

public function get_values_for_state_hash( $value )

Prepares the value that will be hashed on form display as part of the state.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe default value.

Returns

  • null | array

Since: 3.0

Source: includes/fields/class-gf-field-consent.php:660