AjaxFormTrait.php in Chaos Tool Suite (ctools) 8.3
File
src/Form/AjaxFormTrait.php
View source
<?php
namespace Drupal\ctools\Form;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
trait AjaxFormTrait {
public static function getAjaxAttributes() {
return [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 'auto',
]),
];
}
public static function getAjaxButtonAttributes() {
return NestedArray::mergeDeep(AjaxFormTrait::getAjaxAttributes(), [
'class' => [
'button',
'button--small',
'button-action',
],
]);
}
}