You are here

public static function BaseSettings::chartPreviewSubmit in Charts 8.4

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

Submit callback for the preview button.

File

src/Element/BaseSettings.php, line 1069

Class

BaseSettings
Provides a form element for setting a chart.

Namespace

Drupal\charts\Element

Code

public static function chartPreviewSubmit(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $element_parents = array_slice($triggering_element['#parents'], 0, -2);
  $id_prefix = implode('-', $element_parents);

  // Getting the current element state.
  $element_state = ChartDataCollectorTable::getElementState($element_parents, $form_state);
  $element_state[$id_prefix . '__open_preview'] = TRUE;

  // Updating form state storage.
  ChartDataCollectorTable::setElementState($element_parents, $form_state, $element_state);
  $form_state
    ->setRebuild();
}