Postcode

Categories

Component ID

2749241

Component name

Postcode

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

513

Component created

Component changed

Component body

This module defines a (validated) postcode field for …

  • Form-API - This is mainly useful for developers.
  • A webform-component including form_builder support.

Dependencies

Usage of the form-API type

$form['postcode1'] = [
  '#type' => 'postcode',
  '#title' => t('UK Postcode'),
  // The postcode must be valid for the given country. (optional)
  // If no country is specified the "first" country where the value
  // is a valid postcode is assumed.
  '#postcode_country' => 'GB',
  // form-#parents of a form-field that is used to select the country. (optional)
  // Only evaluated if #postcode_country is empty.
  '#postcode_country_parents' => ['select', 'country'],
];