file FormsSmartDescriptionsLimit.php

Namespace

Drupal\bootstrap\Plugin\Setting\General\Forms
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Setting\General\Forms;
  3. use Drupal\bootstrap\Plugin\Setting\SettingBase;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * The "forms_smart_descriptions_limit" theme setting.
  8. *
  9. * @ingroup plugins_setting
  10. *
  11. * @BootstrapSetting(
  12. * id = "forms_smart_descriptions_limit",
  13. * type = "textfield",
  14. * title = @Translation("Smart form descriptions maximum character limit"),
  15. * defaultValue = "250",
  16. * description = @Translation("Prevents descriptions from becoming tooltips by checking the character length of the description (HTML is not counted towards this limit). To disable this filtering criteria, leave an empty value."),
  17. * groups = {
  18. * "general" = @Translation("General"),
  19. * "forms" = @Translation("Forms"),
  20. * },
  21. * )
  22. */
  23. class FormsSmartDescriptionsLimit extends SettingBase {
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  28. $setting = $this->getSettingElement($form, $form_state);
  29. $setting->setProperty('states', [
  30. 'visible' => [
  31. ':input[name="forms_smart_descriptions"]' => ['checked' => TRUE],
  32. ],
  33. ]);
  34. }
  35. }

Classes

Name Description
FormsSmartDescriptionsLimit The "forms_smart_descriptions_limit" theme setting.