public function FieldsSettingsForm::multiStepAjax in Diff 8
Ajax handler for multi-step buttons.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
Return value
array The fields form for a plugin.
File
- src/
Form/ FieldsSettingsForm.php, line 359
Class
- FieldsSettingsForm
- Configure fields with their diff builder plugin settings.
Namespace
Drupal\diff\FormCode
public function multiStepAjax(array $form, FormStateInterface $form_state) {
$trigger = $form_state
->getTriggeringElement();
if (isset($trigger['#op'])) {
$op = $trigger['#op'];
// Pick the elements that need to receive the ajax-new-content effect.
$updated_rows = [];
$updated_columns = [];
switch ($op) {
case 'edit':
$updated_rows = [
$trigger['#field_key'],
];
$updated_columns = array(
'plugin',
);
break;
case 'update':
case 'cancel':
$updated_rows = [
$trigger['#field_key'],
];
$updated_columns = array(
'plugin',
'settings_edit',
);
break;
}
foreach ($updated_rows as $name) {
foreach ($updated_columns as $key) {
$element =& $form['fields'][$name][$key];
$element['#prefix'] = '<div class="ajax-new-content">' . (isset($element['#prefix']) ? $element['#prefix'] : '');
$element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . '</div>';
}
}
}
// Return the whole table.
return $form['fields'];
}