Skip to main content

GF_Field_Radio

Source: includes/fields/class-gf-field-radio.php:9

Details

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

Properties

PropertyTypeDescription
$_supports_state_validationboolIndicates if this field supports state validation.

Methods

MethodDescription
get_form_editor_field_description()Returns the field's form editor description.
get_form_editor_field_icon()Returns the field's form editor icon.
is_state_valid()Determines the if the field has been tampered with before submission.
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.
get_value_for_state_validation()Returns the value to use when the state is validated.
get_field_container_tag()Returns the HTML tag for the field container.
add_aria_description()Determine if we should add the aria description to a radio input.
get_choice_html()Returns the choice HTML.
get_legacy_choice_html()Returns the choice HTML.
get_value_merge_tag()Gets merge tag values.
get_value_save_input()Sanitize and format the value before it is saved to the Entry Object. For radio fields with 'other' option enabled, extracts the user-entered text from the array.
get_other_choice_value_from_post()Extracts the "other" choice value from POST data, handling nested repeater arrays.
sanitize_entry_value()Strip scripts and some HTML tags.
get_filter_operators()Returns the filter operators for the current field.
get_entry_inputs()Override to return null instead of the array of inputs in case this is a choice field.

Method Reference

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-radio.php:33

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-radio.php:46

is_state_valid()

public function is_state_valid( $value )

Determines the if the field has been tampered with before submission.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe submitted value.

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field-radio.php:82

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.

Parameters

NameTypeDefaultDescription
$key

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field-radio.php:97

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-radio.php:110

get_value_for_state_validation()

public function get_value_for_state_validation( $value )

Returns the value to use when the state is validated.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe submitted value.

Returns

  • array

Since: 3.0

Source: includes/fields/class-gf-field-radio.php:137

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-radio.php:159

add_aria_description()

public function add_aria_description( $checked, $choice_id )

Determine if we should add the aria description to a radio input.

Parameters

NameTypeDefaultDescription
$checkedstringThe checked attribute or a blank string.
$choice_idintThe choice number.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field-radio.php:279

get_choice_html()

public function get_choice_html( $choice, &$choice_id, $value, $disabled_text, $is_admin )

Returns the choice HTML.

Parameters

NameTypeDefaultDescription
$choicearrayThe choice properties.
&$choice_idintThe choice number.
$valuestringThe current field value.
$disabled_textstringThe disabled attribute or an empty string.
$is_adminboolIndicates if this is the form editor or entry detail page.

Returns

  • string

Since:

  • 2.4.17
  • 2.7 (Added gchoice_other_control class to Other choice text input.)

Source: includes/fields/class-gf-field-radio.php:308

get_legacy_choice_html()

public function get_legacy_choice_html( $choice, &$choice_id, $value, $disabled_text, $is_admin )

Returns the choice HTML.

Parameters

NameTypeDefaultDescription
$choicearrayThe choice properties.
&$choice_idintThe choice number.
$valuestringThe current field value.
$disabled_textstringThe disabled attribute or an empty string.
$is_adminboolIndicates if this is the form editor or entry detail page.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field-radio.php:398

get_value_merge_tag()

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

Gets merge tag values.

Parameters

NameTypeDefaultDescription
$valuearray | stringThe value of the input.
$input_idstringThe input ID to use.
$entryarrayThe Entry Object.
$formarrayThe Form Object
$modifierstringThe modifier passed.
$raw_valuearray | stringThe raw value of the input.
$url_encodeboolIf the result should be URL encoded.
$esc_htmlboolIf the HTML should be escaped.
$formatstringThe format that the value should be.
$nl2brboolIf the nl2br function should be used.

Returns

  • string — The processed merge tag.

Since: Unknown

Source: includes/fields/class-gf-field-radio.php:521

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. For radio fields with 'other' option enabled, extracts the user-entered text from the array.

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 index if the field is inside a repeater.

Returns

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

Since: 3.0.0

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

get_other_choice_value_from_post()

public function get_other_choice_value_from_post( $item_index=null )

Extracts the "other" choice value from POST data, handling nested repeater arrays.

Parameters

NameTypeDefaultDescription
$item_indexstring | nullnullOptional explicit index (for get_value_save_input).

Returns

  • string — The extracted other value, or empty string if not found.

Since: 3.0.0

Source: includes/fields/class-gf-field-radio.php:630

sanitize_entry_value()

public function sanitize_entry_value( $value, $form_id )

Strip scripts and some HTML tags.

Parameters

NameTypeDefaultDescription
$valuestringThe field value to be processed.
$form_idintThe ID of the form currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field-radio.php:669

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-radio.php:698

get_entry_inputs()

public function get_entry_inputs()

Override to return null instead of the array of inputs in case this is a choice field.

Returns

  • array | null

Since: 2.9

Source: includes/fields/class-gf-field-radio.php:711