function ConfigTestForm::save

Same name and namespace in other branches
  1. 11.x core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::save()
  2. 10 core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::save()
  3. 9 core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::save()
  4. 8.9.x core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::save()

Overrides EntityForm::save

File

core/modules/config/tests/config_test/src/ConfigTestForm.php, line 139

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();
  $label = $entity->label();
  if ($status === SAVED_UPDATED) {
    $this->messenger()
      ->addStatus("{$label} configuration has been updated.");
  }
  else {
    $this->messenger()
      ->addStatus("{$label} configuration has been created.");
  }
  $form_state->setRedirectUrl($this->entity
    ->toUrl('collection'));
  return $status;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.