class FancyConfigForm in Better Login Form Configuration 8
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\better_login_form_config\Form\FancyConfigForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of FancyConfigForm
1 string reference to 'FancyConfigForm'
- better_login_form_config.routing.yml in better_login_form_config/
better_login_form_config.routing.yml - better_login_form_config/better_login_form_config.routing.yml
File
- better_login_form_config/
src/ Form/ FancyConfigForm.php, line 16 - Contains \Drupal\better_login_form_config\Form\FancyConfigForm.
Namespace
Drupal\better_login_form_config\FormView source
class FancyConfigForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'fancy_login_config_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$login_form_config = $this
->config('fancy_login.settings');
$form['login_form_setting'] = [
'#type' => 'details',
'#title' => $this
->t('Login Form'),
'#open' => TRUE,
];
$form['login_form_setting']['form_title'] = array(
'#type' => 'textfield',
'#title' => t('Login Form Title'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'form-title',
),
),
'#required' => TRUE,
'#default_value' => !empty($login_form_config
->get('form_title')) ? $login_form_config
->get('form_title') : 'User account',
);
$form['login_form_setting']['username_label'] = array(
'#type' => 'textfield',
'#title' => t('Username Label'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'username-label',
),
),
'#required' => TRUE,
'#default_value' => !empty($login_form_config
->get('username_label')) ? $login_form_config
->get('username_label') : 'Username',
);
$form['login_form_setting']['username_description'] = array(
'#type' => 'textfield',
'#title' => t('Username Description'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'username-description',
),
),
'#default_value' => !empty($login_form_config
->get('username_description')) ? $login_form_config
->get('username_description') : '',
);
$form['login_form_setting']['password_label'] = array(
'#type' => 'textfield',
'#title' => t('Password Label'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'password-label',
),
),
'#required' => TRUE,
'#default_value' => !empty($login_form_config
->get('password_label')) ? $login_form_config
->get('password_label') : 'Password',
);
$form['login_form_setting']['password_description'] = array(
'#type' => 'textfield',
'#title' => t('Password Description'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'password-description',
),
),
'#default_value' => !empty($login_form_config
->get('password_description')) ? $login_form_config
->get('password_description') : 'Enter the password that accompanies your username.',
);
$form['login_form_setting']['login_button'] = array(
'#type' => 'textfield',
'#title' => t('Login button text'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#attributes' => array(
'class' => array(
'login-button',
),
),
'#default_value' => !empty($login_form_config
->get('login_button')) ? $login_form_config
->get('login_button') : 'Log in',
);
$form['login_form_setting']['include_login'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config
->get('include_login')) ? $login_form_config
->get('include_login') : 0,
'#title' => t('Exclude login Form Template'),
);
$form['forgot_form_setting'] = [
'#type' => 'details',
'#title' => $this
->t('Forgot Password Form'),
'#open' => false,
];
$form['forgot_form_setting']['forgot_form_title'] = array(
'#type' => 'textfield',
'#title' => t('Forgot Form Title '),
'#size' => 60,
'#attributes' => array(
'class' => array(
'forgot_form_title',
),
),
'#required' => TRUE,
'#default_value' => !empty($login_form_config
->get('forgot_form_title')) ? $login_form_config
->get('forgot_form_title') : 'Forgot your password? ',
);
$form['forgot_form_setting']['forgot_form_username'] = array(
'#type' => 'textfield',
'#title' => t('User Name or Email Label '),
'#size' => 60,
'#attributes' => array(
'class' => array(
'forgot_form_username',
),
),
'#required' => TRUE,
'#default_value' => !empty($login_form_config
->get('forgot_form_username')) ? $login_form_config
->get('forgot_form_username') : 'Username or email address. ',
);
$form['forgot_form_setting']['forgot_form_username_desc'] = array(
'#type' => 'textfield',
'#title' => t('User Name or Email Description '),
'#size' => 60,
'#attributes' => array(
'class' => array(
'forgot_form_username_desc',
),
),
'#default_value' => !empty($login_form_config
->get('forgot_form_username_desc')) ? $login_form_config
->get('forgot_form_username_desc') : 'Password reset instructions will be sent to your registered email address.',
);
$form['forgot_form_setting']['include_forgot_template'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config
->get('include_forgot_template')) ? $login_form_config
->get('include_forgot_template') : 0,
'#title' => t('Exclude Forgot Password Form Template'),
);
$form['register_form_setting'] = [
'#type' => 'details',
'#title' => $this
->t('Register Form'),
'#open' => false,
];
$form['register_form_setting']['register_form_title'] = array(
'#type' => 'textfield',
'#title' => t('Register Form Title '),
'#size' => 60,
'#required' => TRUE,
'#attributes' => array(
'class' => array(
'register_form_title',
),
),
'#default_value' => !empty($login_form_config
->get('register_form_title')) ? $login_form_config
->get('register_form_title') : 'Register',
);
$form['register_form_setting']['register_form_mail'] = array(
'#type' => 'textfield',
'#title' => t('Register Mail Label '),
'#size' => 60,
'#required' => TRUE,
'#attributes' => array(
'class' => array(
'register_form_mail',
),
),
'#default_value' => !empty($login_form_config
->get('register_form_mail')) ? $login_form_config
->get('register_form_mail') : 'Email address',
);
$form['register_form_setting']['register_mail_desc'] = array(
'#type' => 'textfield',
'#title' => t(' EMail Description '),
'#size' => 90,
'#maxlength' => 255,
'#attributes' => array(
'class' => array(
'register_mail_desc',
),
),
'#default_value' => !empty($login_form_config
->get('register_mail_desc')) ? $login_form_config
->get('register_mail_desc') : 'A valid email address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email.',
);
$form['register_form_setting']['register_form_name'] = array(
'#type' => 'textfield',
'#title' => t('Register Name Label '),
'#size' => 60,
'#required' => TRUE,
'#attributes' => array(
'class' => array(
'register_form_name',
),
),
'#default_value' => !empty($login_form_config
->get('register_form_name')) ? $login_form_config
->get('register_form_title') : 'Username',
);
$form['register_form_setting']['register_form_name_desc'] = array(
'#type' => 'textfield',
'#title' => t('User Name Description '),
'#size' => 90,
'#maxlength' => 255,
'#attributes' => array(
'class' => array(
'register_form_name_desc',
),
),
'#default_value' => !empty($login_form_config
->get('register_form_name_desc')) ? $login_form_config
->get('register_form_name_desc') : "Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign.",
);
$form['register_form_setting']['register_form_button'] = array(
'#type' => 'textfield',
'#title' => t('Register button Text'),
'#size' => 60,
'#attributes' => array(
'class' => array(
'register_form_button',
),
),
'#default_value' => !empty($login_form_config
->get('register_form_button')) ? $login_form_config
->get('register_form_button') : "Create new account",
);
$form['register_form_setting']['include_regi_template'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config
->get('include_regi_template')) ? $login_form_config
->get('include_regi_template') : 0,
'#title' => t('Exclude Register Form Template'),
);
$form['create_account'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config
->get('create_account')) ? $login_form_config
->get('create_account') : 0,
'#title' => t('Create New Account'),
);
$form['forgot_password'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config
->get('forgot_password')) ? $login_form_config
->get('forgot_password') : 0,
'#title' => t('Forgot your password?'),
);
/*$form['login_block'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($login_form_config->get('login_block')) ? $login_form_config->get('login_block') : 0,
'#title' => t('Configure the login block as well?'),
);
*/
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('fancy_login.settings');
$config
->set('form_title', $form_state
->getValue('form_title'));
$config
->set('username_label', $form_state
->getValue('username_label'));
$config
->set('username_description', $form_state
->getValue('username_description'));
$config
->set('password_label', $form_state
->getValue('password_label'));
$config
->set('password_description', $form_state
->getValue('password_description'));
$config
->set('login_button', $form_state
->getValue('login_button'));
$config
->set('create_account', $form_state
->getValue('create_account'));
$config
->set('forgot_password', $form_state
->getValue('forgot_password'));
//$config->set('login_block', $form_state->getValue('login_block'));
$config
->set('forgot_form_title', $form_state
->getValue('forgot_form_title'));
$config
->set('register_form_title', $form_state
->getValue('register_form_title'));
$config
->set('register_form_mail', $form_state
->getValue('register_form_mail'));
$config
->set('register_mail_desc', $form_state
->getValue('register_mail_desc'));
$config
->set('register_form_name', $form_state
->getValue('register_form_name'));
$config
->set('register_form_name_desc', $form_state
->getValue('register_form_name_desc'));
$config
->set('forgot_form_username_desc', $form_state
->getValue('forgot_form_username_desc'));
$config
->set('forgot_form_username', $form_state
->getValue('forgot_form_username'));
$config
->set('forgot_form_button', $form_state
->getValue('forgot_form_button'));
$config
->set('include_login', $form_state
->getValue('include_login'));
$config
->set('include_regi_template', $form_state
->getValue('include_regi_template'));
$config
->set('include_forgot_template', $form_state
->getValue('include_forgot_template'));
$config
->save();
return parent::submitForm($form, $form_state);
drupal_flush_all_caches();
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'fancy_login.settings',
];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FancyConfigForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
FancyConfigForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
FancyConfigForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
FancyConfigForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |