You are here

public function ConfigTestForm::save in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::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

core/modules/config/tests/config_test/src/ConfigTestForm.php, line 167
Contains \Drupal\config_test\ConfigTestForm.

Class

ConfigTestForm
Form controller for the test config edit forms.

Namespace

Drupal\config_test

Code

public function save(array $form, FormStateInterface $form_state) {
  $entity = $this->entity;
  $status = $entity
    ->save();
  if ($status === SAVED_UPDATED) {
    drupal_set_message(format_string('%label configuration has been updated.', array(
      '%label' => $entity
        ->label(),
    )));
  }
  else {
    drupal_set_message(format_string('%label configuration has been created.', array(
      '%label' => $entity
        ->label(),
    )));
  }
  $form_state
    ->setRedirectUrl($this->entity
    ->urlInfo('collection'));
}