You are here

public function Php::buildOptionsForm in PHP 8

Same name in this branch
  1. 8 src/Plugin/views/argument_default/Php.php \Drupal\php\Plugin\views\argument_default\Php::buildOptionsForm()
  2. 8 src/Plugin/views/argument_validator/Php.php \Drupal\php\Plugin\views\argument_validator\Php::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentDefaultPluginBase::buildOptionsForm

File

src/Plugin/views/argument_default/Php.php, line 32

Class

Php
Default argument plugin to provide a PHP code block.

Namespace

Drupal\php\Plugin\views\argument_default

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['code'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('PHP contextual filter code'),
    '#default_value' => $this->options['code'],
    '#description' => $this
      ->t('Enter PHP code that returns a value to use for this filter. Do not use <?php ?>. You must return only a single value for just this filter. Some variables are available: the view object will be "$view". The argument handler will be "$argument", for example you may change the title used for substitutions for this argument by setting "argument->validated_title".'),
  ];

  // Only do this if using one simple standard form gadget.
  $this
    ->checkAccess($form, 'code');
}