private function AjaxFormBase::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 AjaxFormBase::alterForm()
- AjaxFormBase::bindAjaxForm in src/
Form/ AjaxFormBase.php
File
- src/
Form/ AjaxFormBase.php, line 195
Class
- AjaxFormBase
- 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);
}
}
}