public function Instances::removeAjax in Smart Date 3.x
Same name and namespace in other branches
- 8.2 modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
- 3.0.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
- 3.1.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
- 3.2.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
- 3.3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::removeAjax()
- 3.4.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 457
Class
- Instances
- Provides listings of instances (with overrides) for a specified rule.
Namespace
Drupal\smart_date_recur\ControllerCode
public function removeAjax(SmartDateRule $rrule, int $index) {
$this
->setSmartDateRule($rrule);
$this
->setUpdateButton(FALSE);
$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;
}