You are here

public function ViewsBootstrapMediaObject::buildOptionsForm in Views Bootstrap 8.4

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/style/ViewsBootstrapMediaObject.php \Drupal\views_bootstrap\Plugin\views\style\ViewsBootstrapMediaObject::buildOptionsForm()

Render the given style.

Overrides StylePluginBase::buildOptionsForm

File

src/Plugin/views/style/ViewsBootstrapMediaObject.php, line 48

Class

ViewsBootstrapMediaObject
Style plugin to render each item as a row in a Bootstrap Media Object.

Namespace

Drupal\views_bootstrap\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $fields = $this->displayHandler
    ->getFieldLabels(TRUE);
  $optionalFields = [
    '' => $this
      ->t('<None>'),
  ];
  $optionalFields += $this->displayHandler
    ->getFieldLabels(TRUE);
  $form['heading_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Heading field'),
    '#options' => $fields,
    '#required' => TRUE,
    '#default_value' => $this->options['heading_field'],
    '#description' => $this
      ->t('Select the field that will be used as the media object heading.'),
  ];
  $form['image_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Image field'),
    '#options' => $this->displayHandler
      ->getFieldLabels(TRUE),
    '#required' => TRUE,
    '#default_value' => $this->options['image_field'],
    '#description' => $this
      ->t('Select the field that will be used as the media object image.'),
  ];
  $form['image_class'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Image Alignment'),
    '#options' => [
      'media-left' => $this
        ->t('Left'),
      'media-right' => $this
        ->t('Right'),
      'media-middle' => $this
        ->t('Middle'),
    ],
    '#default_value' => $this->options['image_class'],
    '#description' => $this
      ->t('Align the media object image left or right.'),
  ];
  $form['body_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Body field'),
    '#options' => $optionalFields,
    '#required' => FALSE,
    '#default_value' => $this->options['body_field'],
    '#description' => $this
      ->t('Select the field that will be used as the media object body.'),
  ];
}