From d80f1bc9c772c9d7bb5aa7fb396cbaf86c0b3527 Mon Sep 17 00:00:00 2001 From: Dibyajyoti Panda Date: Fri, 8 Apr 2016 01:24:42 +0530 Subject: [PATCH] Add weight option --- config/install/tfa.settings.yml | 3 ++- config/schema/tfa.schema.yml | 3 +++ src/Form/SettingsForm.php | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/install/tfa.settings.yml b/config/install/tfa.settings.yml index 665722c..2b850b9 100644 --- a/config/install/tfa.settings.yml +++ b/config/install/tfa.settings.yml @@ -3,4 +3,5 @@ setup_plugins: { } send_plugins: { } login_plugins: { } validate_plugins: { } -validate_weights: { } \ No newline at end of file +validate_weights: { } +weight: 9 \ No newline at end of file diff --git a/config/schema/tfa.schema.yml b/config/schema/tfa.schema.yml index fa165d2..96e20b1 100644 --- a/config/schema/tfa.schema.yml +++ b/config/schema/tfa.schema.yml @@ -20,3 +20,6 @@ tfa.settings: validate_weights: type: sequence label: 'Validation plugins weights' + weight: + type: integer + label: 'Weight of the tab' diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 8629b5d..8767a5d 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -115,6 +115,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $config->get('enabled'), '#description' => t('Enable TFA for account authentication.'), ); + + // Option to set tfa tab in userprofile + $form['weight'] = array( + '#type' => 'weight', + '#title' => $this->t('Weight of the tfa tab'), + '#default_value' => $config->get('weight'), + '#delta' => 30, + ); //@TODO Figure out why we allow multiple validation plugins? if (count($validate_plugins)) { @@ -285,6 +293,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('tfa.settings') ->set('enabled', $form_state->getValue('tfa_enabled')) + ->set('weight', $form_state->getValue('weight')) ->set('setup_plugins', array_filter($form_state->getValue('tfa_setup'))) ->set('send_plugins', array_filter($form_state->getValue('tfa_send'))) ->set('login_plugins', array_filter($form_state->getValue('tfa_login')))