public static function FieldHelper::getAutocompleteAttribute in Address 8
Gets the autocomplete attribute for the given AddressField value.
Source: https://html.spec.whatwg.org/multipage/forms.html#autofill.
Parameters
string $field: An AddressField value.
Return value
string The autocomplete attribute.
1 call to FieldHelper::getAutocompleteAttribute()
- Address::addressElements in src/
Element/ Address.php - Builds the format-specific address elements.
File
- src/
FieldHelper.php, line 50
Class
- FieldHelper
- Provides property names and autocomplete attributes for AddressField values.
Namespace
Drupal\addressCode
public static function getAutocompleteAttribute($field) {
$autocomplete_mapping = [
AddressField::ADMINISTRATIVE_AREA => 'address-level1',
AddressField::LOCALITY => 'address-level2',
AddressField::DEPENDENT_LOCALITY => 'address-level3',
AddressField::POSTAL_CODE => 'postal-code',
AddressField::SORTING_CODE => 'sorting-code',
AddressField::ADDRESS_LINE1 => 'address-line1',
AddressField::ADDRESS_LINE2 => 'address-line2',
AddressField::ORGANIZATION => 'organization',
AddressField::FAMILY_NAME => 'family-name',
AddressField::ADDITIONAL_NAME => 'additional-name',
AddressField::GIVEN_NAME => 'given-name',
];
return isset($autocomplete_mapping[$field]) ? $autocomplete_mapping[$field] : NULL;
}