You are here

class AddressPcaAddress in Loqate 2.x

Same name and namespace in other branches
  1. 8 modules/pca_address/src/Element/AddressPcaAddress.php \Drupal\pca_address\Element\AddressPcaAddress

Provides an advanced PCA address form element.

Usage example:


$form['address'] = [
  '#type' => 'pca_address_advanced',
  '#pca_fields' => [
    [
      'element' => PcaAddressElement::ADDRESS_LOOKUP,
    ],
    [
      'element' => PcaAddressElement::LINE1,
      'field' => PcaAddressField::LINE1,
      'mode' => PcaAddressMode::POPULATE,
    ],
    ...
  ],
  '#pca_options' => [
    'key' => config_key_id, // Defaults to key from config.
    'countries' => ['codesList' => 'USA,CAN'],
    'setCountryByIP' => false,
    ...
  ],
  '#show_address_fields' => FALSE,
  '#allow_manual_input' => TRUE,
  ...
];

Plugin annotation

@FormElement("pca_address_advanced");

Hierarchy

Expanded class hierarchy of AddressPcaAddress

See also

\Drupal\address\Element\Address

File

modules/pca_address/src/Element/AddressPcaAddress.php, line 42

Namespace

Drupal\pca_address\Element
View source
class AddressPcaAddress extends Address {
  use PcaAddressElementTrait;

  /**
   * {@inheritdoc}
   */
  public function getInfo() {
    $info = parent::getInfo();
    $info['#process'][] = [
      get_class($this),
      'processPcaAddress',
    ];
    $info['#attached']['library'][] = 'loqate/element.pca_address.address.js';
    return $this
      ->buildElementGetInfo() + $info;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddressPcaAddress::getInfo public function
PcaAddressElementTrait::addAddressLabelField private static function Adds a address label field.
PcaAddressElementTrait::addAddressLookupField private static function Adds a lookup field.
PcaAddressElementTrait::buildElementGetInfo public function Get the default settings for the field widget.
PcaAddressElementTrait::preparePcaFieldMapping private static function Processes field mapping output.
PcaAddressElementTrait::preparePcaOptions private static function Processes additional options and overrides.
PcaAddressElementTrait::processPcaAddress public static function Process the PCA address form element.
PcaAddressElementTrait::wrapAddressFieldsInit private static function Alters the original render array in favor of PCA.