You are here

function Table::options_submit in Views PDF 8

Options form storage.

File

src/Plugin/views/style/Table.php, line 298

Class

Table
Style plugin to render each item as a row in a table.

Namespace

Drupal\tardis\Plugin\views\style

Code

function options_submit(&$form, &$form_state) {
  $default_font_style = $this->display->handler
    ->get_option('default_font_style');
  foreach ($form_state['values']['style_options']['info'] as $id => $field) {

    // Reset to default, if the elements are equal to the default settings.
    if (count(array_diff($default_font_style, $field['header_style']['text']['font_style'])) == 0 && count(array_diff($field['header_style']['text']['font_style'], $default_font_style)) == 0) {
      $form_state['values']['style_options']['info'][$id]['header_style']['text']['font_style'] = NULL;
    }
    if ($field['header_style']['text']['align'] == $this->display->handler
      ->get_option('default_text_align')) {
      $form_state['values']['style_options']['info'][$id]['header_style']['text']['align'] = NULL;
    }
    if ($field['header_style']['text']['hyphenate'] == $this->display->handler
      ->get_option('default_text_hyphenate')) {
      $form_state['values']['style_options']['info'][$id]['header_style']['text']['hyphenate'] = NULL;
    }

    // Reset to default, if the elements are equal to the default settings.
    if (count(array_diff($default_font_style, $field['body_style']['text']['font_style'])) == 0 && count(array_diff($field['body_style']['text']['font_style'], $default_font_style)) == 0) {
      $form_state['values']['style_options']['info'][$id]['body_style']['text']['font_style'] = NULL;
    }
    if ($field['body_style']['text']['align'] == $this->display->handler
      ->get_option('default_text_align')) {
      $form_state['values']['style_options']['info'][$id]['body_style']['text']['align'] = NULL;
    }
    if ($field['body_style']['text']['hyphenate'] == $this->display->handler
      ->get_option('default_text_hyphenate')) {
      $form_state['values']['style_options']['info'][$id]['body_style']['text']['hyphenate'] = NULL;
    }
  }
}