private static function ChartDataCollectorTable::tableRowOperation in Charts 5.0.x
Same name and namespace in other branches
- 8.4 src/Element/ChartDataCollectorTable.php \Drupal\charts\Element\ChartDataCollectorTable::tableRowOperation()
Performs add or delete operation on the table row.
Parameters
array $element_state: The element state storage.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
string $op: The operation.
null|int $index: The row index.
Return value
array The updated element state storage.
1 call to ChartDataCollectorTable::tableRowOperation()
- ChartDataCollectorTable::tableOperationSubmit in src/
Element/ ChartDataCollectorTable.php - Submit callback for table add and delete operations.
File
- src/
Element/ ChartDataCollectorTable.php, line 600
Class
- ChartDataCollectorTable
- Provides a chart data collector table form element.
Namespace
Drupal\charts\ElementCode
private static function tableRowOperation(array $element_state, FormStateInterface $form_state, $op, $index = NULL) {
if ($op === 'delete') {
// When only one row left we just empty it's columns.
if (count($element_state['data_collector_table']) === 1) {
$row = $element_state['data_collector_table'][$index];
$element_state['data_collector_table'][$index][] = self::emptyRowColumns($row);
return $element_state;
}
unset($element_state['data_collector_table'][$index]);
}
else {
$first_row = current($element_state['data_collector_table']);
$element_state['data_collector_table'][] = self::emptyRowColumns($first_row);
}
return $element_state;
}