private function AjaxFormTrait::alterForm in Forena Reports 8
Parameters
array $elements: Drupal form render array section.
string $callback: Callback to apply to the form submit buttons.
1 call to AjaxFormTrait::alterForm()
- AjaxFormTrait::bindAjaxForm in src/
Form/ AjaxFormTrait.php
File
- src/
Form/ AjaxFormTrait.php, line 158
Class
- AjaxFormTrait
- Class AjaxFormTrait
Namespace
Drupal\forena\FormCode
private function alterForm(&$elements, $callback) {
foreach ($elements as $key => $element) {
if (strpos($key, '#') !== 0 && is_array($element)) {
if (!empty($element['#type'])) {
switch ($element['#type']) {
case 'submit':
if (!isset($element['#ajax'])) {
$elements[$key]['#mode'] = $callback;
$elements[$key]['#ajax'] = [
'callback' => $callback,
'event' => 'click',
];
}
break;
}
}
$this
->alterForm($elements[$key], $callback);
}
}
}