Commit cb7d92cd authored by Julian Pustkuchen's avatar Julian Pustkuchen
Browse files

Issue #3305446 by Anybody, Grevil: Config contains unexpected values after saving settings

parent 6aa4b468
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -99,3 +99,16 @@ function photoswipe_requirements($phase) {
function photoswipe_update_8313() {
  \Drupal::messenger()->addStatus('IMPORTANT: If you\'re already using the newly introduced "Photoswipe RESPONSIVE" field formatter, you have to set them manually AGAIN after this update. Regular photoswipe formatter is NOT affected. For details see #3271648.');
}

/**
 * Remove unwanted config value from settings form: actions, form_build_id,
 * form_token, form_id.
 */
function photoswipe_update_8314() {
  \Drupal::configFactory()->getEditable('photoswipe.settings')
      ->clear('actions')
      ->clear('form_build_id')
      ->clear('form_token')
      ->clear('form_id')
      ->save();
}
+9 −16
Original line number Diff line number Diff line
@@ -21,26 +21,19 @@ class PhotoswipeAdminSettings extends ConfigFormBase {
    /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this->config('photoswipe.settings');

    foreach (Element::children($form) as $variable) {
      $config->set($variable, $form_state->getValue($form[$variable]['#parents']));
    }
    $config->save();

    if (method_exists($this, '_submitForm')) {
      $this->_submitForm($form, $form_state);
    }

    parent::submitForm($form, $form_state);
  protected function getEditableConfigNames() {
    return ['photoswipe.settings'];
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return ['photoswipe.settings'];
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('photoswipe.settings')
    ->set('photoswipe_always_load_non_admin', $form_state->getValue('photoswipe_always_load_non_admin'))
    ->save();

    parent::submitForm($form, $form_state);
  }

  /**