4 * Contains \Drupal\bootstrap\Plugin\Form\NodePreviewFormSelect.
7 namespace Drupal\bootstrap\Plugin\Form;
9 use Drupal\bootstrap\Annotation\BootstrapForm;
10 use Drupal\bootstrap\Bootstrap;
11 use Drupal\bootstrap\Utility\Element;
12 use Drupal\Core\Form\FormStateInterface;
15 * Implements hook_form_FORM_ID_alter().
17 * @ingroup plugins_form
19 * @BootstrapForm("node_preview_form_select")
21 class NodePreviewFormSelect extends FormBase {
26 public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
27 $form->addClass(['form-inline', 'bg-info', 'text-center', 'clearfix']);
30 $options = $form->backlink->getProperty('options', []);
32 $form->backlink->addClass(isset($options['attributes']['class']) ? $options['attributes']['class'] : []);
33 $form->backlink->addClass(['btn', 'btn-info', 'pull-left']);
34 $form->backlink->setButtonSize();
35 $form->backlink->setIcon(Bootstrap::glyphicon('chevron-left'));
37 // Ensure the UUID is set.
38 if ($uuid = $form->uuid->getProperty('value')) {
39 $options['query'] = ['uuid' => $uuid];
42 // Override the options attributes.
43 $options['attributes'] = $form->backlink->getAttributes()->getArrayCopy();
45 $form->backlink->setProperty('options', $options);
49 $form->view_mode->addClass('pull-right', $form::WRAPPER);