You are here

class super_loginSettingsForm in Super Login 8

Configure Super Login settings for this site.

Hierarchy

Expanded class hierarchy of super_loginSettingsForm

File

src/Super_loginSettingsForm.php, line 12

Namespace

Drupal\super_login
View source
class super_loginSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'super_login_admin_settings';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'super_login.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('super_login.settings');
    $form['text'] = [
      '#type' => 'fieldset',
      '#title' => t('Text String Options'),
    ];
    $form['text']['login_title'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Log In Text'),
      '#description' => $this
        ->t('Enter the text to be displayed above the login form.'),
      '#default_value' => $config
        ->get('super_login.login_title'),
    ];
    $form['text']['forgot_pw_text'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Forgot Password Link Text'),
      '#description' => $this
        ->t("Enter the text to be displayed as the forgot password's link anchor text."),
      '#default_value' => $config
        ->get('super_login.forgot_pw_text'),
    ];
    $form['text']['capslock_msg'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Caps Lock Message'),
      '#description' => $this
        ->t('Enter the text to be displayed when a user tries to enter a password with the caps look on.'),
      '#default_value' => $config
        ->get('super_login.capslock_msg'),
    ];
    $form['text']['new_account_text'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('New Account Text'),
      '#description' => $this
        ->t('Enter the text to be displayed for the new account link.'),
      '#default_value' => $config
        ->get('super_login.new_account_text'),
    ];
    $form['text']['login_text'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Login Title'),
      '#description' => $this
        ->t('Enter the text to be displayed above the username/email login field.'),
      '#default_value' => $config
        ->get('super_login.login_text'),
    ];
    $form['text']['password_reset_title'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Password Reset Title'),
      '#description' => $this
        ->t('Enter the title to be displayed on the password reset page.'),
      '#default_value' => $config
        ->get('super_login.password_reset_title'),
    ];
    $form['text']['back_link'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Back to Login Page Text.'),
      '#description' => $this
        ->t('Enter the text to be displayed for the "back to login page" link.'),
      '#default_value' => $config
        ->get('super_login.back_link'),
    ];
    $form['options'] = [
      '#type' => 'fieldset',
      '#title' => t('Configuration Options'),
    ];
    $options = [
      0 => t('Username or Email Address'),
      1 => t('Username Only'),
      2 => t('Email Address Only'),
    ];
    $form['options']['login_type'] = [
      '#type' => 'radios',
      '#options' => $options,
      '#title' => $this
        ->t('Login Type'),
      '#description' => $this
        ->t('Options to allow logging into the site with.'),
      '#default_value' => $config
        ->get('super_login.login_type'),
    ];
    $form['options']['messages'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Show system messages outside of login form'),
      '#description' => $this
        ->t('Disable this option to display system messages in the default/normal Drupal location'),
      '#default_value' => $config
        ->get('super_login.messages'),
    ];
    $form['options']['css'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable module CSS (stylesheet)'),
      '#description' => $this
        ->t("Disable this option to turn off this module's CSS style sheet. If disabled, you should provide your own styling through your theme's stylesheet."),
      '#default_value' => $config
        ->get('super_login.css'),
    ];
    $form['options']['capslock'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Caps Lock Warning'),
      '#description' => $this
        ->t('Disable this option to turn off the caps lock warning message for the password field.'),
      '#default_value' => $config
        ->get('super_login.capslock'),
    ];
    $form['options']['button_theme'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable replacement of standard submit button with CSS3 theme.'),
      '#disabled' => $config
        ->get('super_login.css') ? FALSE : TRUE,
      '#description' => t('Disable this option to remove the CSS3 theme on the submit buttons.'),
      '#default_value' => $config
        ->get('super_login.button_theme'),
    ];
    $form['options']['autofocus'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable autofocus for username field'),
      '#default_value' => $config
        ->get('super_login.autofocus'),
      '#description' => t('Enable this option for browsers to automatically set the focus in username field.'),
    ];
    $form['options']['placeholder'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable "placeholder" text within fields.'),
      '#description' => $this
        ->t('Disable this option to remove the placeholder text within the login and password reset fields.'),
      '#default_value' => $config
        ->get('super_login.placeholder'),
    ];
    $form['options']['placeholders'] = [
      '#type' => 'container',
      '#states' => [
        'visible' => [
          ':input[name="placeholder"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    $form['options']['placeholders']['login_placeholder'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Login Placeholder'),
      '#description' => $this
        ->t('Enter the text to be displayed as placeholder for the username/email login field.'),
      '#default_value' => $config
        ->get('super_login.login_placeholder'),
    ];
    $form['options']['placeholders']['pass_placeholder'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Password Placeholder'),
      '#description' => $this
        ->t('Enter the text to be displayed as placeholder for the password field.'),
      '#default_value' => $config
        ->get('super_login.pass_placeholder'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this
      ->config('super_login.settings');
    $config
      ->set('super_login.login_text', $form_state
      ->getValue('login_text'));
    $config
      ->set('super_login.forgot_pw_text', $form_state
      ->getValue('forgot_pw_text'));
    $config
      ->set('super_login.capslock_msg', $form_state
      ->getValue('capslock_msg'));
    $config
      ->set('super_login.new_account_text', $form_state
      ->getValue('new_account_text'));
    $config
      ->set('super_login.login_title', $form_state
      ->getValue('login_title'));
    $config
      ->set('super_login.password_reset_title', $form_state
      ->getValue('password_reset_title'));
    $config
      ->set('super_login.back_link', $form_state
      ->getValue('back_link'));
    $config
      ->set('super_login.css', $form_state
      ->getValue('css'));
    $config
      ->set('super_login.messages', $form_state
      ->getValue('messages'));
    $config
      ->set('super_login.button_theme', $form_state
      ->getValue('button_theme'));
    $config
      ->set('super_login.capslock', $form_state
      ->getValue('capslock'));
    $config
      ->set('super_login.placeholder', $form_state
      ->getValue('placeholder'));
    $config
      ->set('super_login.login_type', $form_state
      ->getValue('login_type'));
    $config
      ->set('super_login.login_placeholder', $form_state
      ->getValue('login_placeholder'));
    $config
      ->set('super_login.pass_placeholder', $form_state
      ->getValue('pass_placeholder'));
    $config
      ->set('super_login.autofocus', $form_state
      ->getValue('autofocus'));
    $config
      ->save();
    parent::submitForm($form, $form_state);
    $module_data = \Drupal::service('extension.list.module')
      ->reset()
      ->getList();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
super_loginSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
super_loginSettingsForm::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
super_loginSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
super_loginSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.