You are here

public function PostTypeForm::save in Open Social 8.9

Same name and namespace in other branches
  1. 8 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  2. 8.2 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  3. 8.3 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  4. 8.4 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  5. 8.5 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  6. 8.6 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  7. 8.7 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  8. 8.8 modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  9. 10.3.x modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  10. 10.0.x modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  11. 10.1.x modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::save()
  12. 10.2.x modules/social_features/social_post/src/Form/PostTypeForm.php \Drupal\social_post\Form\PostTypeForm::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

modules/social_features/social_post/src/Form/PostTypeForm.php, line 48

Class

PostTypeForm
Class PostTypeForm.

Namespace

Drupal\social_post\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $post_type = $this->entity;
  $status = $post_type
    ->save();
  switch ($status) {
    case SAVED_NEW:
      drupal_set_message($this
        ->t('Created the %label Post type.', [
        '%label' => $post_type
          ->label(),
      ]));
      break;
    default:
      drupal_set_message($this
        ->t('Saved the %label Post type.', [
        '%label' => $post_type
          ->label(),
      ]));
  }
  $form_state
    ->setRedirectUrl($post_type
    ->toUrl('collection'));
}