You are here

public function IndexForm::save in Elasticsearch Connector 8

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

Form submission handler for the 'save' action.

Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.

Parameters

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

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

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Overrides EntityForm::save

File

src/Form/IndexForm.php, line 275
Contains \Drupal\elasticsearch_connector\Form\IndexForm.

Class

IndexForm
Form controller for node type forms.

Namespace

Drupal\elasticsearch_connector\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $index = $this->entity;
  $index
    ->save();
  drupal_set_message(t('Index %label has been added.', array(
    '%label' => $index
      ->label(),
  )));
  $form_state
    ->setRedirect('elasticsearch_connector.clusters');
}