View source
<?php
namespace Drupal\smart_date_recur\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\smart_date_recur\Entity\SmartDateOverride;
class SmartDateOverrideDeleteAjaxForm extends FormBase {
public function getFormId() {
return "smart_date_recur_delete_override_ajaxform";
}
public function buildForm(array $form, FormStateInterface $form_state, SmartDateOverride $entity = NULL) {
$cancelurl = new Url('smart_date_recur.instances', [
'rrule' => (int) $entity->rrule->value,
'modal' => TRUE,
]);
$submiturl = new Url('smart_date_recur.instance.revert.ajax', [
'entity' => $entity
->id(),
'confirm' => 1,
]);
$form['#prefix'] = '<div id="manage-instances">';
$form['#suffix'] = '</div>';
$form['message'] = [
'#markup' => '<p>' . $this
->t('Revert this Instance?') . '</p>',
];
$form['delete'] = [
'#type' => 'link',
'#title' => $this
->t('Revert'),
'#attributes' => [
'class' => [
'button',
'button--primary',
'use-ajax',
],
],
'#url' => $submiturl,
'#cache' => [
'contexts' => [
'url.query_args:destination',
],
],
];
$form['cancel'] = [
'#type' => 'link',
'#title' => $this
->t('Cancel'),
'#attributes' => [
'class' => [
'button',
'use-ajax',
],
],
'#url' => $cancelurl,
'#cache' => [
'contexts' => [
'url.query_args:destination',
],
],
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}