public function Node::buildOptionsForm

Same name in this branch
  1. 9.x drupal/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php \Drupal\node\Plugin\views\field\Node::buildOptionsForm()
  2. 9.x drupal/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php \Drupal\node\Plugin\views\argument_validator\Node::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentValidatorPluginBase::buildOptionsForm

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php, line 35
Definition of Drupal\node\Plugin\views\argument_validator\Node.

Class

Node
Validate whether an argument is an acceptable node.

Namespace

Drupal\node\Plugin\views\argument_validator

Code

public function buildOptionsForm(&$form, &$form_state) {
  $types = node_type_get_types();
  $options = array();
  foreach ($types as $type => $info) {
    $options[$type] = check_plain(t($info->name));
  }
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#options' => $options,
    '#default_value' => $this->options['types'],
    '#description' => t('Choose one or more content types to validate with.'),
  );
  $form['access'] = array(
    '#type' => 'checkbox',
    '#title' => t('Validate user has access to the content'),
    '#default_value' => $this->options['access'],
  );
  $form['access_op'] = array(
    '#type' => 'radios',
    '#title' => t('Access operation to check'),
    '#options' => array(
      'view' => t('View'),
      'update' => t('Edit'),
      'delete' => t('Delete'),
    ),
    '#default_value' => $this->options['access_op'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[validate][options][node][access]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['nid_type'] = array(
    '#type' => 'select',
    '#title' => t('Filter value format'),
    '#options' => array(
      'nid' => t('Node ID'),
      'nids' => t('Node IDs separated by , or +'),
    ),
    '#default_value' => $this->options['nid_type'],
  );
}