You are here

public function GeocoderProviderAddForm::buildForm in Geocoder 8.3

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

string $geocoder_provider_id: The Geocoder provider ID.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/GeocoderProviderAddForm.php, line 27

Class

GeocoderProviderAddForm
Provides a form for Geocoder provider add forms.

Namespace

Drupal\geocoder\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, string $geocoder_provider_id = NULL) : array {
  if (isset($geocoder_provider_id)) {
    $this->entity
      ->setPlugin($geocoder_provider_id);
  }

  // Derive the label and type from the Geocoder provider definition.
  $definition = $this->entity
    ->getPluginDefinition();
  if (isset($definition['name'])) {
    $this->entity
      ->set('label', $definition['name']);
  }
  return parent::buildForm($form, $form_state);
}