1 views_plugin_query_default.inc views_plugin_query_default::options_form(&$form, &$form_state)

Add settings for the ui.

Overrides views_plugin_query::options_form


core/modules/views/plugins/views_plugin_query_default.inc, line 239
Defines the default query object.


Object used to create a SELECT query.


function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  $form['disable_sql_rewrite'] = array(
    '#title' => t('Disable SQL rewriting'),
    '#description' => t('Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->options['disable_sql_rewrite']),
    '#suffix' => '<div class="messages warning sql-rewrite-warning js-hide">' . t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.') . '</div>',
  $form['distinct'] = array(
    '#type' => 'checkbox',
    '#title' => t('Distinct'),
    '#description' => t('This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.'),
    '#default_value' => !empty($this->options['distinct']),
  $form['pure_distinct'] = array(
    '#type' => 'checkbox',
    '#title' => t('Pure Distinct'),
    '#description' => t('This will prevent views from adding the base column to the distinct field. If this is not selected and the base column is a primary key, then a non-pure distinct will not function properly because the primary key is always unique.'),
    '#default_value' => !empty($this->options['pure_distinct']),
    '#states' => array(
      'visible' => array(
        ':input[name="query[options][distinct]"]' => array('checked' => TRUE),
  $form['slave'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Slave Server'),
    '#description' => t('This will make the query attempt to connect to a slave server if available.  If no slave server is defined or available, it will fall back to the default server.'),
    '#default_value' => !empty($this->options['slave']),
  $form['query_comment'] = array(
    '#type' => 'textfield',
    '#title' => t('Query Comment'),
    '#description' => t('If set, this comment will be embedded in the query and passed to the SQL server. This can be helpful for logging or debugging.'),
    '#default_value' => $this->options['query_comment'],
  $form['query_tags'] = array(
    '#type' => 'textfield',
    '#title' => t('Query Tags'),
    '#description' => t('If set, these tags will be appended to the query and can be used to identify the query in a module. This can be helpful for altering queries.'),
    '#default_value' => implode(', ', $this->options['query_tags']),
    '#element_validate' => array('views_element_validate_tags'),