You are here

public function BlazyViewsFieldPluginBase::buildOptionsForm in Blazy 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/views/field/BlazyViewsFieldPluginBase.php \Drupal\blazy\Plugin\views\field\BlazyViewsFieldPluginBase::buildOptionsForm()

Default options form that provides the label widget that all fields should have.

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/BlazyViewsFieldPluginBase.php, line 77

Class

BlazyViewsFieldPluginBase
Defines a base views field plugin to render a preview of supported fields.

Namespace

Drupal\blazy\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $definitions = $this
    ->getScopedFormElements();
  $form += $this
    ->blazyAdmin()
    ->baseForm($definitions);
  foreach ($this
    ->getDefaultValues() as $key => $default) {
    if (isset($form[$key])) {
      $form[$key]['#default_value'] = isset($this->options[$key]) ? $this->options[$key] : $default;
      $form[$key]['#weight'] = 0;
      if (in_array($key, [
        'box_style',
        'box_media_style',
      ])) {
        $form[$key]['#empty_option'] = $this
          ->t('- None -');
      }
    }
  }
  if (isset($form['view_mode'])) {
    $form['view_mode']['#description'] = $this
      ->t('Will fallback to this view mode, else entity label.');
  }
  parent::buildOptionsForm($form, $form_state);
}