file NodePreviewFormSelect.php

Namespace

Drupal\bootstrap\Plugin\Form
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Form;
  3. use Drupal\bootstrap\Bootstrap;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * Implements hook_form_FORM_ID_alter().
  8. *
  9. * @ingroup plugins_form
  10. *
  11. * @BootstrapForm("node_preview_form_select")
  12. */
  13. class NodePreviewFormSelect extends FormBase {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  18. $form->addClass(['form-inline', 'bg-info', 'text-center', 'clearfix']);
  19. // Backlink.
  20. $options = $form->backlink->getProperty('options', []);
  21. $form->backlink->addClass(isset($options['attributes']['class']) ? $options['attributes']['class'] : []);
  22. $form->backlink->addClass(['btn', 'btn-info', 'pull-left']);
  23. $form->backlink->setButtonSize();
  24. $form->backlink->setIcon(Bootstrap::glyphicon('chevron-left'));
  25. // Ensure the UUID is set.
  26. if ($uuid = $form->uuid->getProperty('value')) {
  27. $options['query'] = ['uuid' => $uuid];
  28. }
  29. // Override the options attributes.
  30. $options['attributes'] = $form->backlink->getAttributes()->getArrayCopy();
  31. $form->backlink->setProperty('options', $options);
  32. // View mode.
  33. $form->view_mode->addClass('pull-right', $form::WRAPPER);
  34. }
  35. }

Classes