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
| Property | Type | Description |
|---|---|---|
$type | string | Declare the field type. |
$duplicatable | bool | Whether there can be more than one of this field type per form. |
$repeatable | bool | Whether the field can be used in a repeater. Consent field is currently not supported in repeaters. |
$checked_indicator_url | string | Checked indicator URL. |
$checked_indicator_markup | string | Checked indicator image markup. |
$_supports_state_validation | bool | Indicates if this field supports state validation. |
Methods
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$data | array | [] | 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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The Form Object currently being processed. | |
$value | array | [] | The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. |
$entry | null | array | null | Null 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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$description | string | The field description. | |
$css_class | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$extra_ids | array | 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The value to be saved. | |
$form | array | The Form object currently being processed. | |
$input_name | string | The input name used when accessing the $_POST. | |
$entry_id | int | The ID of the entry currently being processed. | |
$entry | array | The entry currently being processed. | |
$repeater_index | string | '' | 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The 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_id | string | The field or input ID from the merge tag currently being processed. | |
$entry | array | The Entry Object currently being processed. | |
$form | array | The Form Object currently being processed. | |
$modifier | string | The merge tag modifier. e.g. value. | |
$raw_value | string | array | The raw field value from before any formatting was applied to $value. | |
$url_encode | bool | Indicates if the urlencode function may have been applied to the $value. | |
$esc_html | bool | Indicates if the esc_html function may have been applied to the $value. | |
$format | string | The format requested for the location the merge is being used. Possible values: html, text or url. | |
$nl2br | bool | Indicates 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | The Entry Object currently being processed. | |
$field_id | string | The field or input ID currently being processed. | |
$columns | array | The properties for the columns being displayed on the entry list page. | |
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | [] | The entry. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$format | string | 'html' | The format requested for the location the merge is being used. Possible values: html, text or url. |
$media | string | 'screen' | The location where the value will be displayed. Possible values: screen or email. |
Returns
string
Since:
2.42.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
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry currently being processed. | |
$input_id | string | '' | The field or input ID. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$is_csv | bool | false | false | Is 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
| Name | Type | Default | Description |
|---|---|---|---|
$revision_id | int | Revision 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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The default value. |
Returns
null|array
Since: 3.0
Source: includes/fields/class-gf-field-consent.php:660