function BrokenHandlerTrait::buildOptionsForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait::buildOptionsForm()
  2. 8.9.x core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait::buildOptionsForm()
  3. 10 core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait::buildOptionsForm()

Provides a form to edit options for this plugin.

See also

\Drupal\views\Plugin\views\PluginBase::defineOptions()

File

core/modules/views/src/Plugin/views/BrokenHandlerTrait.php, line 52

Class

BrokenHandlerTrait
A Trait for Views broken handlers.

Namespace

Drupal\views\Plugin\views

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $description_top = $this->t('The handler for this item is broken or missing. The following details are available:');
    foreach ($this->definition['original_configuration'] as $key => $value) {
        if (is_scalar($value)) {
            $items[] = new FormattableMarkup('@key: @value', [
                '@key' => $key,
                '@value' => $value,
            ]);
        }
    }
    $description_bottom = $this->t('Installing the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.');
    $form['description'] = [
        '#type' => 'container',
        '#attributes' => [
            'class' => [
                'js-form-item',
                'form-item',
                'description',
            ],
        ],
        'description_top' => [
            '#markup' => '<p>' . $description_top . '</p>',
        ],
        'detail_list' => [
            '#theme' => 'item_list',
            '#items' => $items,
        ],
        'description_bottom' => [
            '#markup' => '<p>' . $description_bottom . '</p>',
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.