You are here

class UserLoginBarForm in UserLoginBar 8

Defines a form to configure maintenance settings for this site.

Hierarchy

  • class \Drupal\userloginbar\Form\UserLoginBarForm extends \Drupal\system\SystemConfigFormBase

Expanded class hierarchy of UserLoginBarForm

1 string reference to 'UserLoginBarForm'
userloginbar.routing.yml in ./userloginbar.routing.yml
userloginbar.routing.yml

File

lib/Drupal/userloginbar/Form/UserLoginBarForm.php, line 14
Contains \Drupal\system\Form\SiteMaintenanceModeForm.

Namespace

Drupal\userloginbar\Form
View source
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);
  }

}

Members