You are here

trait AjaxFormTrait in Context 8

Same name and namespace in other branches
  1. 8.4 src/Form/AjaxFormTrait.php \Drupal\context\Form\AjaxFormTrait
  2. 8.0 src/Form/AjaxFormTrait.php \Drupal\context\Form\AjaxFormTrait

Provides helper methods for using an AJAX modal. This is a copy of the ctools AjaxFormTrait.

Hierarchy

4 files declare their use of AjaxFormTrait
BlockFormBase.php in src/Reaction/Blocks/Form/BlockFormBase.php
Blocks.php in src/Plugin/ContextReaction/Blocks.php
ContextEditForm.php in modules/context_ui/src/Form/ContextEditForm.php
ContextListBuilder.php in modules/context_ui/src/ContextListBuilder.php

File

src/Form/AjaxFormTrait.php, line 17
Contains \Drupal\context\Form\AjaxFormTrait.

Namespace

Drupal\context\Form
View source
trait AjaxFormTrait {

  /**
   * Gets attributes for use with an AJAX modal.
   *
   * @return array
   */
  public static function getAjaxAttributes() {
    return [
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => Json::encode([
        'width' => 1000,
      ]),
    ];
  }

  /**
   * Gets attributes for use with an add button AJAX modal.
   *
   * @return array
   */
  public static function getAjaxButtonAttributes() {
    return NestedArray::mergeDeep(AjaxFormTrait::getAjaxAttributes(), [
      'class' => [
        'button',
        'button--small',
        'button-action',
      ],
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AjaxFormTrait::getAjaxAttributes public static function Gets attributes for use with an AJAX modal.
AjaxFormTrait::getAjaxButtonAttributes public static function Gets attributes for use with an add button AJAX modal.