You are here

public function AvailableCountriesTrait::countrySettingsForm in Address 8

Builds the field settings form.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.

Return value

array The modified form.

3 calls to AvailableCountriesTrait::countrySettingsForm()
AddressItem::fieldSettingsForm in src/Plugin/Field/FieldType/AddressItem.php
Returns a form for the field-level settings.
CountryItem::fieldSettingsForm in src/Plugin/Field/FieldType/CountryItem.php
Returns a form for the field-level settings.
ZoneItem::fieldSettingsForm in src/Plugin/Field/FieldType/ZoneItem.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/AvailableCountriesTrait.php, line 44

Class

AvailableCountriesTrait
Allows field types to limit the available countries.

Namespace

Drupal\address\Plugin\Field\FieldType

Code

public function countrySettingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $element['available_countries'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Available countries'),
    '#description' => $this
      ->t('If no countries are selected, all countries will be available.'),
    '#options' => \Drupal::service('address.country_repository')
      ->getList(),
    '#default_value' => $this
      ->getSetting('available_countries'),
    '#multiple' => TRUE,
    '#size' => 10,
  ];
  return $element;
}