YamlFormHandlerDeleteForm.php in YAML Form 8
File
src/Form/YamlFormHandlerDeleteForm.php
View source
<?php
namespace Drupal\yamlform\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\yamlform\YamlFormInterface;
class YamlFormHandlerDeleteForm extends ConfirmFormBase {
protected $yamlform;
protected $yamlformHandler;
public function getQuestion() {
return $this
->t('Are you sure you want to delete the @handler handler from the %yamlform form?', [
'%yamlform' => $this->yamlform
->label(),
'@handler' => $this->yamlformHandler
->label(),
]);
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function getCancelUrl() {
return $this->yamlform
->toUrl('handlers-form');
}
public function getFormId() {
return 'yamlform_handler_delete_form';
}
public function buildForm(array $form, FormStateInterface $form_state, YamlFormInterface $yamlform = NULL, $yamlform_handler = NULL) {
$this->yamlform = $yamlform;
$this->yamlformHandler = $this->yamlform
->getHandler($yamlform_handler);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->yamlform
->deleteYamlFormHandler($this->yamlformHandler);
drupal_set_message($this
->t('The form handler %name has been deleted.', [
'%name' => $this->yamlformHandler
->label(),
]));
$form_state
->setRedirectUrl($this->yamlform
->toUrl('handlers-form'));
}
}