You are here

public function ViewsPhp::buildOptionsForm in Views PHP 8

Same name in this branch
  1. 8 src/Plugin/views/area/ViewsPhp.php \Drupal\views_php\Plugin\views\area\ViewsPhp::buildOptionsForm()
  2. 8 src/Plugin/views/filter/ViewsPhp.php \Drupal\views_php\Plugin\views\filter\ViewsPhp::buildOptionsForm()
  3. 8 src/Plugin/views/sort/ViewsPhp.php \Drupal\views_php\Plugin\views\sort\ViewsPhp::buildOptionsForm()
  4. 8 src/Plugin/views/access/ViewsPhp.php \Drupal\views_php\Plugin\views\access\ViewsPhp::buildOptionsForm()
  5. 8 src/Plugin/views/cache/ViewsPhp.php \Drupal\views_php\Plugin\views\cache\ViewsPhp::buildOptionsForm()
  6. 8 src/Plugin/views/field/ViewsPhp.php \Drupal\views_php\Plugin\views\field\ViewsPhp::buildOptionsForm()

Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

Overrides FilterPluginBase::buildOptionsForm

File

src/Plugin/views/filter/ViewsPhp.php, line 54
Contains \Drupal\views_php\Plugin\views\filter\ViewsPhp.

Class

ViewsPhp
A handler to filter a view using PHP defined by the administrator.

Namespace

Drupal\views_php\Plugin\views\filter

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form += views_php_form_element($this, array(
    'use_php_setup',
    t('Use setup code'),
    t('If checked, you can provide PHP code to be run once right before execution of the view. This may be useful to define functions to be re-used in the value and/or output code.'),
  ), array(
    'php_setup',
    t('Setup code'),
    t('Code to run right before execution of the view.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
  ));
  $form += views_php_form_element($this, FALSE, array(
    'php_filter',
    t('Filter code'),
    t('If the code returns TRUE the current row is removed from the results.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
    '$row',
    '$data',
  ));
  $form['#attached']['library'][] = 'views_php/drupal.views_php';
}