You are here

UserLoginBarForm.php in UserLoginBar 8

File

lib/Drupal/userloginbar/Form/UserLoginBarForm.php
View source
<?php

/**
* @file
* Contains \Drupal\system\Form\SiteMaintenanceModeForm.
*/
namespace Drupal\userloginbar\Form;

use Drupal\system\SystemConfigFormBase;

/**
* Defines a form to configure maintenance settings for this site.
*/
class UserLoginBarForm extends SystemConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'userloginbar_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state) {
    $config = $this->configFactory
      ->get('userloginbar.settings');

    // Defines form elements for sliders content type
    $form['text'] = array(
      '#type' => 'fieldset',
      '#title' => t('Userloginbar Settings'),
    );
    $form['text']['disable_welcome_box'] = array(
      '#type' => 'checkbox',
      '#title' => t('Check this box, if you want to disable welcome box when the user logs in!'),
      '#default_value' => $config
        ->get('disable_welcome_box'),
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->configFactory
      ->get('userloginbar.settings')
      ->set('disable_welcome_box', $form_state['values']['disable_welcome_box'])
      ->save();
    parent::submitForm($form, $form_state);
  }

}
?>

<?php

Classes

Namesort descending Description
UserLoginBarForm Defines a form to configure maintenance settings for this site.