You are here

public function AdminSettingForm::submitForm in Dynamic Banner 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 FormInterface::submitForm

File

src/forms/AdminSettingForm.php, line 64

Class

AdminSettingForm

Namespace

Drupal\dynamic_banner\forms

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $display = $form_state
    ->getValue('display_setting');
  \Drupal::configFactory()
    ->getEditable('dynamic_banner.settings')
    ->set('dynamic_banner_display_setting', $display)
    ->save();

  //\Drupal::config('dynamic_banner.settings')->get('dynamic_banner_display_setting');
  $errors = $form_state
    ->getValue('display_errors');

  // todo fix this
  if ($errors == 0) {
    $errorDb = TRUE;
  }
  else {
    $errorDb = FALSE;
  }
  \Drupal::configFactory()
    ->getEditable('dynamic_banner.settings')
    ->set('dynamic_banner_display_errors', $errorDb)
    ->save();

  //File path
  $filePath = $form_state
    ->getValue('image_save_path');
  \Drupal::configFactory()
    ->getEditable('dynamic_banner.settings')
    ->set('dynamic_banner_file_save_path', $filePath)
    ->save();
  $form_state
    ->setRedirect('cdb.listbanners');
  return;
}