WebformDeleteFormBase.php in Webform 8.5
File
src/Form/WebformDeleteFormBase.php
View source
<?php
namespace Drupal\webform\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\ConfirmFormHelper;
use Drupal\Core\Form\FormStateInterface;
abstract class WebformDeleteFormBase extends ConfirmFormBase implements WebformDeleteFormInterface {
use WebformDialogFormTrait;
public function getFormName() {
return 'webform_delete';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#attributes']['class'][] = 'confirmation';
$form['#theme'] = 'confirm_form';
$form[$this
->getFormName()] = [
'#type' => 'hidden',
'#value' => 1,
];
$form['#title'] = $this
->getQuestion();
$form['warning'] = $this
->getWarning();
$form['description'] = $this
->getDescription();
$details = $this
->getDetails();
$confirm_input = $this
->getConfirmInput();
if ($details) {
$form['details'] = $details;
}
if (!$details && $confirm_input) {
$form['hr'] = [
'#markup' => '<p><hr/></p>',
];
}
if ($confirm_input) {
$form['confirm'] = $confirm_input;
}
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->getConfirmText(),
'#button_type' => 'primary',
];
$form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this
->getRequest());
return $this
->buildDialogConfirmForm($form, $form_state);
}
public function getWarning() {
return [
'#type' => 'webform_message',
'#message_type' => 'warning',
'#message_message' => $this
->t('Are you sure you want to delete this?') . '<br/>' . '<strong>' . $this
->t('This action cannot be undone.') . '</strong>',
];
}
public function getDescription() {
return [];
}
public function getDetails() {
return [];
}
public function getConfirmInput() {
return [];
}
public function getConfirmText() {
return $this
->t('Delete');
}
}