You are here

public static function ChartDataCollectorTable::ajaxRefresh in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x src/Element/ChartDataCollectorTable.php \Drupal\charts\Element\ChartDataCollectorTable::ajaxRefresh()

Ajax callback.

File

src/Element/ChartDataCollectorTable.php, line 373

Class

ChartDataCollectorTable
Provides a chart data collector table form element.

Namespace

Drupal\charts\Element

Code

public static function ajaxRefresh(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $operation = $triggering_element['#operation'] ?? '';
  if ($operation === 'csv' || !$operation && $triggering_element['#type'] === 'radio') {
    $length = -2;
  }
  else {
    $length = $operation === 'add' ? -4 : -3;
  }
  $element_parents = array_slice($triggering_element['#array_parents'], 0, $length);
  return NestedArray::getValue($form, $element_parents);
}