AddressPcaAddressWidget.php in Loqate 2.x
File
modules/pca_address/src/Plugin/Field/FieldWidget/AddressPcaAddressWidget.php
View source
<?php
namespace Drupal\pca_address\Plugin\Field\FieldWidget;
use Drupal\address\Plugin\Field\FieldWidget\AddressDefaultWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\loqate\PcaAddressFieldWidgetTrait;
class AddressPcaAddressWidget extends AddressDefaultWidget {
use PcaAddressFieldWidgetTrait;
public static function defaultSettings() {
return self::getFieldWidgetDefaultSettings() + parent::defaultSettings();
}
public function settingsForm(array $form, FormStateInterface $form_state) {
return $this
->buildFieldWidgetsettingsForm(parent::settingsForm($form, $form_state));
}
public function settingsSummary() {
return $this
->buildFieldWidgetSettingsSummary();
}
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$element['address']['#type'] = 'pca_address_advanced';
return $this
->buildFieldWidgetFormElement($element);
}
}