You are here

public function Instances::removeAjax in Smart Date 3.4.x

Same name and namespace in other branches
  1. 8.2 modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
  2. 3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
  3. 3.0.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
  4. 3.1.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
  5. 3.2.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
  6. 3.3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()

Preparing the form for removing a rule instance via Ajax.

Parameters

\Drupal\smart_date_recur\Entity\SmartDateRule $rrule: The rule object.

int $index: Index of the instance to remove.

Return value

\Drupal\Core\Ajax\AjaxResponse The AJAX response object.

1 string reference to 'Instances::removeAjax'
smart_date_recur.routing.yml in modules/smart_date_recur/smart_date_recur.routing.yml
modules/smart_date_recur/smart_date_recur.routing.yml

File

modules/smart_date_recur/src/Controller/Instances.php, line 426

Class

Instances
Provides listings of instances (with overrides) for a specified rule.

Namespace

Drupal\smart_date_recur\Controller

Code

public function removeAjax(SmartDateRule $rrule, int $index) {
  $this
    ->setSmartDateRule($rrule);
  $this
    ->setUseAjax(TRUE);
  $content = \Drupal::formBuilder()
    ->getForm(SmartDateRemoveInstanceForm::class, $rrule, $index, TRUE);
  $content['title']['#markup'] = '<p>' . $content['#title'] . '</p>';
  $form['#attached']['library'][] = 'core/drupal.ajax';
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#manage-instances', $content));
  return $response;
}