You are here

public function DropDownLoginAdminForm::submitForm in Drop Down Login 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/DropDownLoginAdminForm.php, line 186

Class

DropDownLoginAdminForm
Class SettingsForm.

Namespace

Drupal\drop_down_login\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $config = $this
    ->config('drop_down_login.admin.settings');
  $config
    ->set('drop_down_login_want_myaccount', $form_state
    ->getValue('drop_down_login_setting'));
  $config
    ->set('drop_down_login_myaccount_links', $form_state
    ->getValue('drop_down_login_myaccount_links'));

  // Storing order.
  $drop_down_login_myaccount_links = $form_state
    ->getValue('drop_down_login_myaccount_links');
  $weight = [];
  foreach ($drop_down_login_myaccount_links['table'] as $key => $value) {
    $weight[] = $key;
  }
  $config
    ->set('num_rows', $weight);
  $config
    ->save();
}