You are here

class YamlFormTemplatesSubmissionPreviewForm in YAML Form 8

Preview form submission form.

Hierarchy

Expanded class hierarchy of YamlFormTemplatesSubmissionPreviewForm

File

modules/yamlform_templates/src/YamlFormTemplatesSubmissionPreviewForm.php, line 16

Namespace

Drupal\yamlform_templates
View source
class YamlFormTemplatesSubmissionPreviewForm extends YamlFormSubmissionForm {
  use YamlFormDialogTrait;

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    if ($this
      ->isModalDialog()) {

      // Disable validation.
      $form['#attributes']['novalidate'] = 'novalidate';

      // Display form title in modal.
      $form['title'] = [
        '#markup' => $this
          ->getYamlForm()
          ->label(),
        '#prefix' => '<h1>',
        '#suffix' => '</h1>',
        '#weight' => -101,
      ];

      // Remove type from 'actions' and add modal 'actions'.
      unset($form['actions']['#type']);
      $form['modal_actions'] = [
        '#type' => 'actions',
      ];
      $form['modal_actions']['select'] = [
        '#type' => 'link',
        '#title' => $this
          ->t('Select'),
        '#url' => Url::fromRoute('entity.yamlform.duplicate_form', [
          'yamlform' => $this
            ->getYamlForm()
            ->id(),
        ]),
        '#attributes' => YamlFormDialogHelper::getModalDialogAttributes(640, [
          'button',
          'button--primary',
        ]),
      ];
      $form['modal_actions']['close'] = [
        '#type' => 'submit',
        '#value' => $this
          ->t('Close'),
        '#ajax' => [
          'callback' => '::closeDialog',
          'event' => 'click',
        ],
      ];
    }
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    if ($this
      ->isModalDialog()) {
      $form_state
        ->clearErrors();
    }
    else {
      parent::validateForm($form, $form_state);
    }
  }

  /**
   * Close dialog.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return bool|\Drupal\Core\Ajax\AjaxResponse
   *   An AJAX response that display validation error messages.
   */
  public function closeDialog(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response
      ->addCommand(new CloseDialogCommand());
    return $response;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityForm::$entityRepository protected property The entity repository service.
ContentEntityForm::$entityTypeBundleInfo protected property The entity type bundle info service.
ContentEntityForm::$time protected property The time service.
ContentEntityForm::addRevisionableFormFields protected function Add revision form fields if the entity enabled the UI.
ContentEntityForm::buildEntity public function Builds an updated entity object based upon the submitted form values. Overrides EntityForm::buildEntity 3
ContentEntityForm::copyFormValuesToEntity protected function Copies top-level form values to entity properties Overrides EntityForm::copyFormValuesToEntity
ContentEntityForm::flagViolations protected function Flags violations for the current form. 4
ContentEntityForm::getBundleEntity protected function Returns the bundle entity of the entity, or NULL if there is none.
ContentEntityForm::getEditedFieldNames protected function Gets the names of all fields edited in the form. 4
ContentEntityForm::getFormDisplay public function Gets the form display. Overrides ContentEntityFormInterface::getFormDisplay
ContentEntityForm::getFormLangcode public function Gets the code identifying the active form language. Overrides ContentEntityFormInterface::getFormLangcode
ContentEntityForm::getNewRevisionDefault protected function Should new revisions created on default.
ContentEntityForm::init protected function Initializes the form state and the entity before the first form build. Overrides EntityForm::init 1
ContentEntityForm::initFormLangcodes protected function Initializes form language code values.
ContentEntityForm::isDefaultFormLangcode public function Checks whether the current form language matches the entity one. Overrides ContentEntityFormInterface::isDefaultFormLangcode
ContentEntityForm::prepareEntity protected function Prepares the entity object before the form is built first. Overrides EntityForm::prepareEntity 1
ContentEntityForm::setFormDisplay public function Sets the form display. Overrides ContentEntityFormInterface::setFormDisplay
ContentEntityForm::showRevisionUi protected function Checks whether the revision form fields should be added to the form.
ContentEntityForm::updateChangedTime public function Updates the changed time of the entity.
ContentEntityForm::updateFormLangcode public function Updates the form language to reflect any change to the entity language.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityForm::$entityTypeManager protected property The entity type manager. 3
EntityForm::$moduleHandler protected property The module handler service.
EntityForm::$operation protected property The name of the current operation.
EntityForm::$privateEntityManager private property The entity manager.
EntityForm::getBaseFormId public function Returns a string identifying the base form. Overrides BaseFormIdInterface::getBaseFormId 5
EntityForm::getEntity public function Gets the form entity. Overrides EntityFormInterface::getEntity
EntityForm::getEntityFromRouteMatch public function Determines which entity will be used by this form from a RouteMatch object. Overrides EntityFormInterface::getEntityFromRouteMatch 1
EntityForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId 10
EntityForm::getOperation public function Gets the operation identifying the form. Overrides EntityFormInterface::getOperation
EntityForm::prepareInvokeAll protected function Invokes the specified prepare hook variant.
EntityForm::processForm public function Process callback: assigns weights and hides extra fields.
EntityForm::setEntityManager public function Sets the entity manager for this form. Overrides EntityFormInterface::setEntityManager
EntityForm::setEntityTypeManager public function Sets the entity type manager for this form. Overrides EntityFormInterface::setEntityTypeManager
EntityForm::setModuleHandler public function Sets the module handler for this form. Overrides EntityFormInterface::setModuleHandler
EntityForm::setOperation public function Sets the operation for this form. Overrides EntityFormInterface::setOperation
EntityForm::__get public function
EntityForm::__set public function
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.
YamlFormDialogTrait::buildDialog protected function Add modal dialog support to a form.
YamlFormDialogTrait::isModalDialog protected function Is the current request for an AJAX modal dialog.
YamlFormDialogTrait::redirectForm protected function Handler dialog redirect after form is submitted.
YamlFormDialogTrait::validateDialog protected function Display validation error messages in modal dialog.
YamlFormSubmissionForm::$elementManager protected property The form element (plugin) manager.
YamlFormSubmissionForm::$entity protected property The form submission. Overrides ContentEntityForm::$entity
YamlFormSubmissionForm::$messageManager protected property The form message manager.
YamlFormSubmissionForm::$requestHandler protected property Form request handler.
YamlFormSubmissionForm::$settings protected property The form settings.
YamlFormSubmissionForm::$sourceEntity protected property The source entity.
YamlFormSubmissionForm::$storage protected property The form submission storage.
YamlFormSubmissionForm::$thirdPartySettingsManager protected property The form third party settings manager.
YamlFormSubmissionForm::$tokenManager protected property The token manager.
YamlFormSubmissionForm::actions protected function Returns an array of supported actions for the current entity form. Overrides EntityForm::actions
YamlFormSubmissionForm::actionsElement protected function Returns the action form element for the current entity form. Overrides EntityForm::actionsElement
YamlFormSubmissionForm::afterBuild public function Form element #after_build callback: Updates the entity with submitted data. Overrides EntityForm::afterBuild
YamlFormSubmissionForm::autosave public function Form submission handler to autosave when there are validation errors.
YamlFormSubmissionForm::checkTotalLimit protected function Check form submission total limits.
YamlFormSubmissionForm::checkUserLimit protected function Check form submission user limit.
YamlFormSubmissionForm::complete public function Form submission handler for the 'complete' action.
YamlFormSubmissionForm::confirmForm public function Form confirm(ation) handler.
YamlFormSubmissionForm::create public static function Instantiates a new instance of this class. Overrides ContentEntityForm::create
YamlFormSubmissionForm::displayCurrentPage protected function Set form wizard current page.
YamlFormSubmissionForm::displayMessages protected function Display draft and previous submission status messages for this form submission.
YamlFormSubmissionForm::draft public function Form submission handler for the 'draft' action.
YamlFormSubmissionForm::draftEnabled protected function Determine if drafts are enabled.
YamlFormSubmissionForm::form public function Gets the actual form array to be built. Overrides ContentEntityForm::form
YamlFormSubmissionForm::getCurrentPage protected function Get the current page's key.
YamlFormSubmissionForm::getCustomForm protected function Get custom form which is displayed instead of the form's elements.
YamlFormSubmissionForm::getFirstPage protected function Get first page's key.
YamlFormSubmissionForm::getLastPage protected function Get last page's key.
YamlFormSubmissionForm::getLimitSourceEntity protected function Get source entity for use with entity limit total and user submissions.
YamlFormSubmissionForm::getNextPage protected function Get next page's key.
YamlFormSubmissionForm::getPages protected function Get visible wizard pages.
YamlFormSubmissionForm::getPreviousPage protected function Get previous page's key.
YamlFormSubmissionForm::getSourceEntity protected function Get the form submission's source entity.
YamlFormSubmissionForm::getYamlForm protected function Get the form submission's form.
YamlFormSubmissionForm::getYamlFormSetting protected function Get a form submission's form setting.
YamlFormSubmissionForm::hiddenElementAfterBuild public static function Form element #after_build callback: Wrap #element_validate so that we suppress element validation errors.
YamlFormSubmissionForm::hiddenElementValidate public static function Form element #element_validate callback: Execute #element_validate and suppress errors.
YamlFormSubmissionForm::hideElements protected function Hide form elements by settings their #access to FALSE.
YamlFormSubmissionForm::isConfidential protected function Returns the form confidential indicator.
YamlFormSubmissionForm::isFormNoValidate protected function Is client side validation disabled (using the form novalidate attribute).
YamlFormSubmissionForm::isGet protected function Is the form being initially loaded via GET method.
YamlFormSubmissionForm::isRoute protected function Determine if the current request is a specific route (name).
YamlFormSubmissionForm::isYamlFormEntityReferenceFromSourceEntity protected function Is the current form an entity reference from the source entity.
YamlFormSubmissionForm::next public function Form submission handler for the 'next' action.
YamlFormSubmissionForm::noValidate public function Form submission validation that does nothing but clear validation errors.
YamlFormSubmissionForm::populateElements protected function Populate form elements.
YamlFormSubmissionForm::prepareElements protected function Prepare form elements.
YamlFormSubmissionForm::prepopulateData protected function Prepopulate element data.
YamlFormSubmissionForm::previous public function Form submission handler for the 'previous' action.
YamlFormSubmissionForm::rebuild public function Form submission handler for the 'rebuild' action.
YamlFormSubmissionForm::save public function Form submission handler for the 'save' action. Overrides EntityForm::save
YamlFormSubmissionForm::setConfirmation protected function Set form state confirmation redirect and message.
YamlFormSubmissionForm::setEntity public function Sets the form entity. Overrides EntityForm::setEntity
YamlFormSubmissionForm::setFormPropertiesFromElements protected function Set the form properties from the elements.
YamlFormSubmissionForm::setTrustedRedirectUrl protected function Set form state to redirect to a trusted redirect response.
YamlFormSubmissionForm::submitForm public function This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state… Overrides ContentEntityForm::submitForm
YamlFormSubmissionForm::wizardSubmit protected function Form submission handler for the wizard submit action.
YamlFormSubmissionForm::__construct public function Constructs a YamlFormSubmissionForm object. Overrides ContentEntityForm::__construct
YamlFormTemplatesSubmissionPreviewForm::buildForm public function Form constructor. Overrides YamlFormSubmissionForm::buildForm
YamlFormTemplatesSubmissionPreviewForm::closeDialog public function Close dialog.
YamlFormTemplatesSubmissionPreviewForm::validateForm public function Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level… Overrides YamlFormSubmissionForm::validateForm