You are here

public function SharebarSettingsForm::submitForm in ShareBar 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/SharebarSettingsForm.php, line 245
Contains \Drupal\sharebar\Form\SharebarSettingsForm.

Class

SharebarSettingsForm
Implements an example form.

Namespace

Drupal\sharebar\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $node_types = node_type_get_types();
  $node_names = node_type_get_names();
  if (is_array($node_names) && count($node_names)) {
    foreach ($node_names as $key => $value) {
      $this
        ->config('sharebar.settings')
        ->set('sharebar_bar_posts_' . $node_types[$key]->type . '_enabled', $form_state
        ->getValue('sharebar_bar_posts_' . $node_types[$key]->type . '_enabled'))
        ->save();
    }
  }
  $this
    ->config('sharebar.settings')
    ->set('sharebar_bar_pages_enabled', $form_state
    ->getValue('sharebar_bar_pages_enabled'))
    ->set('sharebar_bar_horizontal', $form_state
    ->getValue('sharebar_bar_horizontal'))
    ->set('sharebar_bar_oncontent', $form_state
    ->getValue('sharebar_bar_oncontent'))
    ->set('sharebar_bar_credit', $form_state
    ->getValue('sharebar_bar_credit'))
    ->set('sharebar_bar_idcontent', $form_state
    ->getValue('sharebar_bar_idcontent'))
    ->set('sharebar_bar_id', $form_state
    ->getValue('sharebar_bar_id'))
    ->set('sharebar_bar_idhorizontal', $form_state
    ->getValue('sharebar_bar_idhorizontal'))
    ->set('sharebar_bar_toptoffset', $form_state
    ->getValue('sharebar_bar_toptoffset'))
    ->set('sharebar_bar_position', $form_state
    ->getValue('sharebar_bar_position'))
    ->set('sharebar_bar_leftoffset', $form_state
    ->getValue('sharebar_bar_leftoffset'))
    ->set('sharebar_bar_rightoffset', $form_state
    ->getValue('sharebar_bar_rightoffset'))
    ->set('sharebar_bar_width', $form_state
    ->getValue('sharebar_bar_width'))
    ->set('sharebar_bar_swidth', $form_state
    ->getValue('sharebar_bar_swidth'))
    ->set('sharebar_bar_twitter_username', $form_state
    ->getValue('sharebar_bar_twitter_username'))
    ->set('sharebar_bar_background', $form_state
    ->getValue('sharebar_bar_background'))
    ->set('sharebar_bar_border', $form_state
    ->getValue('sharebar_bar_border'))
    ->save();
  parent::submitForm($form, $form_state);
}