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()

Basic options for all sort criteria

Overrides SortPluginBase::buildOptionsForm

File

src/Plugin/views/sort/ViewsPhp.php, line 39
Definition of Drupal\views_php\Plugin\views\sort\ViewsPhp.

Class

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

Namespace

Drupal\views_php\Plugin\views\sort

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_sort',
    t('Sort code'),
    t('The comparison code must return an integer less than, equal to, or greater than zero if the first row should respectively appear before, stay where it was compared to, or appear after the second row.'),
    FALSE,
  ), array(
    '$view',
    '$handler',
    '$static',
    '$row1' => t('Data of row.'),
    '$row2' => t('Data of row to compare against.'),
  ));
  $form['#attached']['library'][] = 'views_php/drupal.views_php';
}