Skip to main content

GF_Field_Address

Source: includes/fields/class-gf-field-address.php:7

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.
get_required_inputs_ids()Defines the IDs of required inputs.
get_field_container_tag()Returns the HTML tag for the field container.
validate()Validates the address field inputs.
get_default_address_type()Retrieve the default address type for this field.
get_selected_address_type()Returns the properties of the selected address type.
get_state_field()Generates state field markup.
get_countries()Returns a list of countries.
get_default_countries()Returns the default array of countries using the ISO 3166-1 alpha-2 code as the key to the country name.
get_country_code()Returns the ISO 3166-1 alpha-2 code for the supplied country name.
get_country_codes()Returns the default countries array updated to use the uppercase country name as the key to the ISO 3166-1 alpha-2 code.
get_us_states()Returns the array of US states and territories.
get_us_state_code()Returns the two-letter US state code from the state name provided.
get_select_option()Returns the option tag for the current choice.
get_first_input_id()Removes the "for" attribute in the field label. Inputs are only allowed one label (a11y) and the inputs already have labels.
get_filter_sub_filters()Returns the sub-filters for the current field.
get_filter_operators()Returns the filter operators for the current field.
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

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-address.php:56

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-address.php:69

get_required_inputs_ids()

public function get_required_inputs_ids()

Defines the IDs of required inputs.

Returns

  • string[]

Since: 2.5

Source: includes/fields/class-gf-field-address.php:80

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-address.php:94

validate()

public function validate( $value, $form )

Validates the address field inputs.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value from get_value_submission().
$formarrayThe Form Object currently being processed.

Returns

  • void

Since:

  • 1.9
  • 2.6.5 (Updated to use set_required_error().)

Source: includes/fields/class-gf-field-address.php:115

get_default_address_type()

public function get_default_address_type( $form_id )

Retrieve the default address type for this field.

Parameters

NameTypeDefaultDescription
$form_idintThe current form ID.

Returns

  • string

Source: includes/fields/class-gf-field-address.php:529

get_selected_address_type()

public function get_selected_address_type()

Returns the properties of the selected address type.

Returns

  • array

Since: 3.0

Source: includes/fields/class-gf-field-address.php:549

get_state_field()

public function get_state_field( $id, $field_id, $state_value, $disabled_text, $form_id, $aria_attributes='', $address_state_field_input='' )

Generates state field markup.

Parameters

NameTypeDefaultDescription
$idintegerInput id.
$field_idintegerField id.
$state_valuestringState value.
$disabled_textstringDisabled attribute.
$form_idintegerCurrent form id being processed.
$aria_attributesstring''Aria attributes values.
$address_state_field_input''

Returns

  • string

Since:

  • unknown
  • 2.5 (added new params $$aria_attributes.)

Source: includes/fields/class-gf-field-address.php:574

get_countries()

public function get_countries()

Returns a list of countries.

Returns

  • array

Since:

  • Unknown
  • 2.4 (Updated to use ISO 3166-1 list of countries.)
  • 2.4.20 (Updated to use GF_Field_Address::get_default_countries() and to sort the countries.)

Source: includes/fields/class-gf-field-address.php:634

get_default_countries()

public function get_default_countries()

Returns the default array of countries using the ISO 3166-1 alpha-2 code as the key to the country name.

Returns

  • array

Since: 2.4.20

Source: includes/fields/class-gf-field-address.php:657

get_country_code()

public function get_country_code( $country_name )

Returns the ISO 3166-1 alpha-2 code for the supplied country name.

Parameters

NameTypeDefaultDescription
$country_namestringThe country name.

Returns

  • string | null

Since: Unknown

Source: includes/fields/class-gf-field-address.php:920

get_country_codes()

public function get_country_codes()

Returns the default countries array updated to use the uppercase country name as the key to the ISO 3166-1 alpha-2 code.

Returns

  • array

Since:

  • Unknown
  • 2.4 (Updated to use ISO 3166-1 list of countries.)
  • 2.4.20 (Updated to use GF_Field_Address::get_default_countries().)

Source: includes/fields/class-gf-field-address.php:935

get_us_states()

public function get_us_states()

Returns the array of US states and territories.

Returns

  • array — The array of US states.

Since: Unknown

Source: includes/fields/class-gf-field-address.php:948

get_us_state_code()

public function get_us_state_code( $state_name )

Returns the two-letter US state code from the state name provided.

Parameters

NameTypeDefaultDescription
$state_namestringThe state name.

Returns

  • string — The two-letter US state code.

Since: Unknown

Source: includes/fields/class-gf-field-address.php:1030

get_select_option()

public function get_select_option( $value, $label, $selected_value )

Returns the option tag for the current choice.

Parameters

NameTypeDefaultDescription
$valuestringThe choice value.
$labelstringThe choice label.
$selected_valuestringThe value for the selected choice.

Returns

  • string

Source: includes/fields/class-gf-field-address.php:1146

get_first_input_id()

public function get_first_input_id( $form )

Removes the "for" attribute in the field label. Inputs are only allowed one label (a11y) and the inputs already have labels.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-address.php:1343

get_filter_sub_filters()

public function get_filter_sub_filters()

Returns the sub-filters for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-address.php:1356

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-address.php:1383

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
$keystring | intThe field or input ID.

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field-address.php:1399

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-address.php:1420