You are here

function views_handler_filter_views_raw_sql::options_form in Views Raw SQL 7

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 views_handler_filter::options_form

File

./views_handler_filter_views_raw_sql.inc, line 38

Class

views_handler_filter_views_raw_sql
A handler to provide a filter that is completely custom SQL by the administrator.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['raw_sql'] = array(
    '#type' => 'textarea',
    '#title' => 'SQL',
    '#description' => t('This SQL will be added to the query as a filter expression.') . ' ' . views_raw_sql_tokens_help(),
    '#default_value' => $this->options['raw_sql'],
    '#required' => TRUE,
  );
  $form['raw_sql_use_having'] = array(
    '#type' => 'checkbox',
    '#title' => 'Use HAVING clause',
    '#description' => t('Add this SQL to the query HAVING clause rather than the WHERE clause'),
    '#default_value' => $this->options['raw_sql_use_having'],
  );
  if (!user_access('edit views raw sql')) {
    $form['raw_sql']['#disabled'] = TRUE;
    $form['raw_sql']['#description'] = t('You lack %permission permission to edit this field.', array(
      '%permission' => 'edit views raw sql',
    ));
  }

  // if
}