You are here

public function GeocoderProviderFormBase::form in Geocoder 8.3

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/GeocoderProviderFormBase.php, line 27

Class

GeocoderProviderFormBase
Base class for forms dealing with Geocoder provider entities.

Namespace

Drupal\geocoder\Form

Code

public function form(array $form, FormStateInterface $form_state) : array {
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $this->entity
      ->label(),
    '#description' => $this
      ->t('Label for the Geocoder provider.'),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $this->entity
      ->id(),
    '#disabled' => !$this->entity
      ->isNew(),
    '#maxlength' => 64,
    '#description' => $this
      ->t('A unique name for this provider. It must only contain lowercase letters, numbers and underscores.'),
    '#machine_name' => [
      'exists' => GeocoderProvider::class . '::load',
    ],
  ];
  $form['plugin'] = [
    '#type' => 'value',
    '#value' => $this->entity
      ->get('plugin'),
  ];
  $plugin = $this->entity
    ->getPlugin();
  if ($plugin && $plugin instanceof PluginFormInterface) {
    $form += $plugin
      ->buildConfigurationForm($form, $form_state);
  }
  return parent::form($form, $form_state);
}