class ModalPageSettingsForm in Modal 5.0.x
Same name and namespace in other branches
- 8.3 src/Form/ModalPageSettingsForm.php \Drupal\modal_page\Form\ModalPageSettingsForm
- 8 src/Form/ModalPageSettingsForm.php \Drupal\modal_page\Form\ModalPageSettingsForm
- 8.2 src/Form/ModalPageSettingsForm.php \Drupal\modal_page\Form\ModalPageSettingsForm
- 4.0.x src/Form/ModalPageSettingsForm.php \Drupal\modal_page\Form\ModalPageSettingsForm
- 4.1.x src/Form/ModalPageSettingsForm.php \Drupal\modal_page\Form\ModalPageSettingsForm
Form for configure messages.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\modal_page\Form\ModalPageSettingsForm uses ModalPageSettersTraitHelper
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of ModalPageSettingsForm
1 string reference to 'ModalPageSettingsForm'
File
- src/
Form/ ModalPageSettingsForm.php, line 15
Namespace
Drupal\modal_page\FormView source
class ModalPageSettingsForm extends ConfigFormBase {
use ModalPageSettersTraitHelper;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var static $instance */
$instance = parent::create($container);
$instance
->setModuleHandler($container
->get('module_handler'));
return $instance;
}
/**
* Set Message info.
*/
public function setMessagesInfo() {
$type = 'status';
// Transform to Info if Info Messages is enabled.
if ($this->moduleHandler
->moduleExists('info_messages')) {
$type = 'info';
}
$this
->messenger()
->addMessage($this
->t('You can create your Modal at <a href="@url_settings">@url_settings</a>', [
'@url_settings' => Url::fromRoute('modal_page.default')
->toString(),
]), $type);
return NULL;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'modal_page_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'modal_page.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$this
->setMessagesInfo();
$config = $this
->config('modal_page.settings');
$form['no_modal_page_external_js'] = [
'#title' => $this
->t("Don't load external JS Bootstrap (bootstrap.min.js)"),
'#type' => 'checkbox',
'#description' => $this
->t('Just check if the js bootstrap (bootstrap.min.js) is already loaded elsewhere.'),
'#default_value' => $config
->get('no_modal_page_external_js'),
];
$form['allowed_tags'] = [
'#type' => 'textarea',
'#title' => $this
->t('Allowed Tags'),
'#description' => $this
->t("A list of HTML tags that can be used, separated by commas(,)."),
'#default_value' => $config
->get('allowed_tags') ?? "h1,h2,a,b,big,code,del,em,i,ins,pre,q,small,span,strong,sub,sup,tt,ol,ul,li,p,br,img",
];
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$no_modal_page_external_js = $form_state
->getValue('no_modal_page_external_js');
$config = $this
->config('modal_page.settings');
$config
->set('no_modal_page_external_js', $no_modal_page_external_js);
$config
->set('allowed_tags', $form_state
->getValue('allowed_tags'));
$config
->save();
PhpStorageFactory::get('twig')
->deleteAll();
parent::submitForm($form, $form_state);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 16 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 3 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 3 |
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. | |
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:: |
72 |
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. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
ModalPageSettersTraitHelper:: |
protected | property | The language manager. | |
ModalPageSettersTraitHelper:: |
protected | property | Module handler. | |
ModalPageSettersTraitHelper:: |
public | function | Set Language Manager. | |
ModalPageSettersTraitHelper:: |
public | function | Set Module Handler. | |
ModalPageSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
ModalPageSettingsForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
ModalPageSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
ModalPageSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
ModalPageSettingsForm:: |
public | function | Set Message info. | |
ModalPageSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
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. | 4 |
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. |