WebformTemplatesSubmissionPreviewForm.php in Webform 8.5
File
modules/webform_templates/src/WebformTemplatesSubmissionPreviewForm.php
View source
<?php
namespace Drupal\webform_templates;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform\Form\WebformDialogFormTrait;
use Drupal\webform\WebformSubmissionForm;
class WebformTemplatesSubmissionPreviewForm extends WebformSubmissionForm {
use WebformDialogFormTrait;
public function buildForm(array $form, FormStateInterface $form_state, $mode = NULL) {
$form = parent::buildForm($form, $form_state, $mode);
if ($this
->isDialog()) {
$form['#attributes']['novalidate'] = 'novalidate';
$form['title'] = [
'#markup' => $this
->getWebform()
->label(),
'#prefix' => '<h1>',
'#suffix' => '</h1>',
'#weight' => -101,
];
unset($form['actions']['#type']);
$form['modal_actions'] = [
'#type' => 'actions',
];
$form['modal_actions']['select'] = [
'#type' => 'link',
'#title' => $this
->t('Select'),
'#url' => Url::fromRoute('entity.webform.duplicate_form', [
'webform' => $this
->getWebform()
->id(),
]),
'#attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW, [
'button',
'button--primary',
]),
];
$form['modal_actions']['close'] = [
'#type' => 'submit',
'#value' => $this
->t('Close'),
'#ajax' => [
'callback' => '::closeDialog',
'event' => 'click',
],
];
}
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($this
->isDialog()) {
$form_state
->clearErrors();
}
else {
parent::validateForm($form, $form_state);
}
}
}