You are here

public function ClusterForm::form in Elasticsearch Connector 8

Same name and namespace in other branches
  1. 8.7 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::form()
  2. 8.2 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::form()
  3. 8.5 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::form()
  4. 8.6 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::form()

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/ClusterForm.php, line 22
Contains Drupal\elasticsearch_connector\Form.

Class

ClusterForm
Provides a form for the Cluster entity.

Namespace

Drupal\elasticsearch_connector\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  if ($form_state
    ->isRebuilding()) {
    $this->entity = $this
      ->buildEntity($form, $form_state);
  }
  $form = parent::form($form, $form_state);

  // Get the entity and attach to the form state.
  $cluster = $this
    ->getEntity();
  if ($cluster
    ->isNew()) {
    $form['#title'] = $this
      ->t('Add Elasticsearch Cluster');
  }
  else {
    $form['#title'] = $this
      ->t('Edit Elasticsearch Cluster @label', array(
      '@label' => $cluster
        ->label(),
    ));
  }
  $this
    ->buildEntityForm($form, $form_state, $cluster);
  return $form;
}