You are here

public function PrintfriendlyConfigForm::submitForm in PrintFriendly & PDF 8

Same name and namespace in other branches
  1. 8.3 src/Form/PrintfriendlyConfigForm.php \Drupal\printfriendly\Form\PrintfriendlyConfigForm::submitForm()
  2. 8.2 src/Form/PrintfriendlyConfigForm.php \Drupal\printfriendly\Form\PrintfriendlyConfigForm::submitForm()

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/PrintfriendlyConfigForm.php, line 206
Contains \Drupal\printfriendly\Form\printfriendlyConfigForm.

Class

PrintfriendlyConfigForm

Namespace

Drupal\printfriendly\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('printfriendly.settings');
  $config
    ->set('printfriendly_types', $form_state
    ->getValue('printfriendly_types'));
  $config
    ->set('printfriendly_display', $form_state
    ->getValue('printfriendly_display'));
  $config
    ->set('printfriendly_page_header', $form_state
    ->getValue('printfriendly_page_header'));
  $config
    ->set('printfriendly_page_custom_header', $form_state
    ->getValue('printfriendly_page_custom_header'));
  $config
    ->set('printfriendly_tagline', $form_state
    ->getValue('printfriendly_tagline'));
  if ($form_state
    ->getValue('printfriendly_page_header') == 'default_logo') {
    $config
      ->set('printfriendly_page_custom_header', '');
    $config
      ->set('printfriendly_tagline', '');
  }
  $config
    ->set('printfriendly_click_delete', $form_state
    ->getValue('printfriendly_click_delete'));
  $config
    ->set('printfriendly_images', $form_state
    ->getValue('printfriendly_images'));
  $config
    ->set('printfriendly_image_style', $form_state
    ->getValue('printfriendly_image_style'));
  $config
    ->set('printfriendly_email', $form_state
    ->getValue('printfriendly_email'));
  $config
    ->set('printfriendly_pdf', $form_state
    ->getValue('printfriendly_pdf'));
  $config
    ->set('printfriendly_print', $form_state
    ->getValue('printfriendly_print'));
  $config
    ->set('printfriendly_custom_css', $form_state
    ->getValue('printfriendly_custom_css'));
  $config
    ->set('printfriendly_website_protocol', $form_state
    ->getValue('printfriendly_website_protocol'));
  $config
    ->set('printfriendly_image', $form_state
    ->getValue('printfriendly_image'));
  $config
    ->save();
  return parent::submitForm($form, $form_state);
}