You are here

public function PostDeleteForm::buildForm in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  2. 8 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  3. 8.2 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  4. 8.3 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  5. 8.4 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  6. 8.5 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  7. 8.6 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  8. 8.7 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  9. 8.8 modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  10. 10.0.x modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  11. 10.1.x modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()
  12. 10.2.x modules/social_features/social_post/src/Form/PostDeleteForm.php \Drupal\social_post\Form\PostDeleteForm::buildForm()

Form constructor.

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

array The form structure.

Overrides ContentEntityDeleteForm::buildForm

1 call to PostDeleteForm::buildForm()
SocialAlbumImageForm::buildForm in modules/social_features/social_album/src/Form/SocialAlbumImageForm.php
Form constructor.
1 method overrides PostDeleteForm::buildForm()
SocialAlbumImageForm::buildForm in modules/social_features/social_album/src/Form/SocialAlbumImageForm.php
Form constructor.

File

modules/social_features/social_post/src/Form/PostDeleteForm.php, line 19

Class

PostDeleteForm
Provides a form for deleting Post entities.

Namespace

Drupal\social_post\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  // Set the redirect url of the cancel button.
  if (\Drupal::request()->query
    ->has('destination')) {
    $destination = \Drupal::destination();
    $path = $destination
      ->get();
    $form['actions']['cancel']['#url'] = Url::fromUserInput($path);
  }
  else {
    $curr_route_parr = \Drupal::routeMatch()
      ->getRawParameters()
      ->getDigits('post');
    $redirect_url = Url::fromRoute('entity.post.edit_form', [
      'post' => $curr_route_parr,
    ]);
    $form['actions']['cancel']['#url'] = $redirect_url;
  }
  return $form;
}