class FormtipsSettingForm in Form Tips 8
Configure Form Tips settings for this site.
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\formtips\Form\FormtipsSettingForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of FormtipsSettingForm
1 string reference to 'FormtipsSettingForm'
File
- src/
Form/ FormtipsSettingForm.php, line 14
Namespace
Drupal\formtips\FormView source
class FormtipsSettingForm extends ConfigFormBase {
/**
* The theme handler.
*
* @var ThemeHandlerInterface
*/
protected $themeHandler;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory, ThemeHandlerInterface $theme_handler) {
parent::__construct($config_factory);
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('theme_handler'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'formtips_setting_form';
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('formtips.settings');
$config_data = $config
->getRawData();
foreach ($config_data as $key => $value) {
$config
->set($key, $form_state
->getValue($key));
}
$config
->save();
parent::submitForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'formtips.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$formtips_settings = $this
->config('formtips.settings');
$themes = [];
/** @var \Drupal\Core\Extension\Extension $theme */
foreach ($this->themeHandler
->listInfo() as $theme_key => $theme) {
$themes[$theme_key] = $theme->info['name'];
}
$form['formtips_themes'] = [
'#type' => 'select',
'#title' => $this
->t('Themes'),
'#description' => $this
->t('Select the themes for which formtips will be applied (selecting none will apply to all).'),
'#options' => $themes,
'#multiple' => TRUE,
'#default_value' => $formtips_settings
->get('formtips_themes'),
];
$form['formtips_trigger_action'] = [
'#type' => 'select',
'#title' => $this
->t('Trigger action'),
'#description' => $this
->t('Select the action that will trigger the display of tooltips.'),
'#options' => [
'hover' => $this
->t('Hover'),
'click' => $this
->t('Click'),
],
'#default_value' => $formtips_settings
->get('formtips_trigger_action'),
];
$form['formtips_selectors'] = [
'#type' => 'textarea',
'#title' => $this
->t('Selectors'),
'#description' => $this
->t("Enter some CSS/XPATH selectors (jQuery compatible) for which you don't want to tigger formtips (one per line)."),
'#default_value' => $formtips_settings
->get('formtips_selectors'),
];
$form['formtips_max_width'] = [
'#type' => 'textfield',
'#title' => $this
->t('Max-width'),
'#description' => $this
->t('Enter a value for the maximum width of the form description tooltip.'),
'#default_value' => $formtips_settings
->get('formtips_max_width'),
];
$form['intent'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Hover intent settings'),
'#description' => $this
->t('Settings for controlling the hover intent plugin.'),
'#states' => [
'visible' => [
':input[name="formtips_trigger_action"]' => [
'value' => 'hover',
],
],
],
];
$form['intent']['formtips_hoverintent'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add hoverIntent plugin'),
'#description' => $this
->t('If the hoverIntent plugin is added by another module or in the theme you can switch this setting off.'),
'#default_value' => $formtips_settings
->get('formtips_hoverintent'),
];
$form['intent']['formtips_interval'] = [
'#type' => 'textfield',
'#title' => $this
->t('Interval'),
'#description' => $this
->t('The number of milliseconds hoverIntent waits between reading/comparing mouse coordinates. When the user\'s mouse first enters the element its coordinates are recorded. The soonest the "over" function can be called is after a single polling interval. Setting the polling interval higher will increase the delay before the first possible "over" call, but also increases the time to the next point of comparison. Default interval: 100'),
'#default_value' => $formtips_settings
->get('formtips_interval'),
];
$form['intent']['formtips_sensitivity'] = [
'#type' => 'textfield',
'#title' => $this
->t('Sensitivity'),
'#description' => $this
->t('If the mouse travels fewer than this number of pixels between polling intervals, then the "over" function will be called. With the minimum sensitivity threshold of 1, the mouse must not move between polling intervals. With higher sensitivity thresholds you are more likely to receive a false positive. Default sensitivity: 7'),
'#default_value' => $formtips_settings
->get('formtips_sensitivity'),
];
$form['intent']['formtips_timeout'] = [
'#type' => 'textfield',
'#title' => $this
->t('Timeout'),
'#description' => $this
->t('A simple delay, in milliseconds, before the "out" function is called. If the user mouses back over the element before the timeout has expired the "out" function will not be called (nor will the "over" function be called). This is primarily to protect against sloppy/human mousing trajectories that temporarily (and unintentionally) take the user off of the target element... giving them time to return. Default timeout: 0'),
'#default_value' => $formtips_settings
->get('formtips_timeout'),
];
return parent::buildForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 | |
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 |
FormtipsSettingForm:: |
protected | property | The theme handler. | |
FormtipsSettingForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
FormtipsSettingForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
FormtipsSettingForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
FormtipsSettingForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
FormtipsSettingForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
FormtipsSettingForm:: |
public | function |
Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase:: |
|
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. |