You are here

public function BlazyViewsFieldPluginBase::options_form in Blazy 7

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

Overrides views_handler_field::options_form

File

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

Class

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

Namespace

Drupal\blazy\Plugin\views\field

Code

public function options_form(&$form, &$form_state) {
  $definitions = $this
    ->getScopedFormElements();
  $form += $this
    ->admin()
    ->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'] = t('- None -');
      }
    }
  }
  if (isset($form['view_mode'])) {
    $form['view_mode']['#description'] = t('Will fallback to this view mode, else entity label.');
  }
  parent::options_form($form, $form_state);
}