class LoginShadowboxSettingsForm in Shadowbox 8
Configure the Shadowbox login settings.
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\login_shadowbox\Form\LoginShadowboxSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of LoginShadowboxSettingsForm
1 string reference to 'LoginShadowboxSettingsForm'
- login_shadowbox.routing.yml in login_shadowbox/
login_shadowbox.routing.yml - login_shadowbox/login_shadowbox.routing.yml
File
- login_shadowbox/
lib/ Drupal/ login_shadowbox/ Form/ LoginShadowboxSettingsForm.php, line 15 - Contains \Drupal\login_shadowbox\Form\LoginShadowboxSettingsForm.
Namespace
Drupal\login_shadowbox\FormView source
class LoginShadowboxSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'login_shadowbox_settings';
}
/**
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*/
public function buildForm(array $form, array &$form_state) {
$config = $this
->config('login_shadowbox.settings');
$form['login_shadowbox_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable shadowbox login'),
'#description' => t('Enable this option if you want to be able to open your login form in shadowbox.'),
'#default_value' => $config
->get('login_shadowbox_enabled'),
);
// Login Dimensions.
$form['login_shadowbox_login'] = array(
'#type' => 'details',
'#title' => t('Login Dimensions'),
'#collapsed' => TRUE,
);
$form['login_shadowbox_login']['login_shadowbox_width'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox login width'),
'#description' => t('The width (in pixels) of shadowbox login form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_width'),
);
$form['login_shadowbox_login']['login_shadowbox_height'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox login height'),
'#description' => t('The height (in pixels) of shadowbox login form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_height'),
);
// Registration Dimensions.
$form['login_shadowbox_register'] = array(
'#type' => 'details',
'#title' => t('Registration Dimensions'),
'#collapsed' => TRUE,
);
$form['login_shadowbox_register']['login_shadowbox_register_width'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox registration width'),
'#description' => t('The width (in pixels) of shadowbox containing the registration form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_register_width'),
);
$form['login_shadowbox_register']['login_shadowbox_register_height'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox registration height'),
'#description' => t('The height (in pixels) of shadowbox containing the registration form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_register_height'),
);
// Reset Password Dimensions.
$form['login_shadowbox_password'] = array(
'#type' => 'details',
'#title' => t('Reset Password Dimensions'),
'#collapsed' => TRUE,
);
$form['login_shadowbox_password']['login_shadowbox_password_width'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox reset password width'),
'#description' => t('The width (in pixels) of shadowbox containing the reset password form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_password_width'),
);
$form['login_shadowbox_password']['login_shadowbox_password_height'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox reset password height'),
'#description' => t('The height (in pixels) of shadowbox containing the reset password form when it appears on screen.'),
'#size' => 5,
'#maxlength' => 4,
'#default_value' => $config
->get('login_shadowbox_password_height'),
);
$form['login_shadowbox_modal'] = array(
'#type' => 'checkbox',
'#title' => t('Shadowbox modal'),
'#description' => t('Check this box to prevent mouse clicks on the overlay from closing Shadowbox.'),
'#default_value' => $config
->get('login_shadowbox_modal'),
);
$form['login_shadowbox_css'] = array(
'#type' => 'textfield',
'#title' => t('Shadowbox login css file'),
'#description' => t('The css file to stylize the shadowbox login dialog.'),
'#size' => 60,
'#maxlength' => 255,
'#default_value' => $config
->get('login_shadowbox_css'),
);
return parent::buildForm($form, $form_state);
}
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, array &$form_state) {
parent::validateForm($form, $form_state);
$width = $form_state['values']['login_shadowbox_width'];
$height = $form_state['values']['login_shadowbox_height'];
if (!is_numeric($width) || $width < 0) {
$this
->setFormError('login_shadowbox_width', $form_state, $this
->t('You must enter a positive number.'));
}
if (!is_numeric($height) || $height < 0) {
$this
->setFormError('login_shadowbox_height', $form_state, $this
->t('You must enter a positive number.'));
}
}
/**
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*/
function submitForm(array &$form, array &$form_state) {
parent::submitForm($form, $form_state);
$this
->config('login_shadowbox.settings')
->set('login_shadowbox_enabled', $form_state['values']['login_shadowbox_enabled'])
->set('login_shadowbox_width', $form_state['values']['login_shadowbox_width'])
->set('login_shadowbox_height', $form_state['values']['login_shadowbox_height'])
->set('login_shadowbox_register_width', $form_state['values']['login_shadowbox_register_width'])
->set('login_shadowbox_register_height', $form_state['values']['login_shadowbox_register_height'])
->set('login_shadowbox_password_width', $form_state['values']['login_shadowbox_password_width'])
->set('login_shadowbox_password_height', $form_state['values']['login_shadowbox_password_height'])
->set('login_shadowbox_modal', $form_state['values']['login_shadowbox_modal'])
->set('login_shadowbox_css', $form_state['values']['login_shadowbox_css'])
->save();
}
}
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. | |
ConfigFormBaseTrait:: |
abstract protected | function | Gets the configuration names that will be editable. | 32 |
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 | |
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. | |
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. | |
LoginShadowboxSettingsForm:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides ConfigFormBase:: |
|
LoginShadowboxSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
LoginShadowboxSettingsForm:: |
function |
Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides ConfigFormBase:: |
||
LoginShadowboxSettingsForm:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormBase:: |
|
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. |