You are here

function views_fields_on_off_form::options_form in Views Fields On/Off 7

Default options form provides the label widget that all fields should have.

Overrides views_handler_field::options_form

File

includes/views/views_fields_on_off_form.inc, line 109
Definition of views_fields_on_off_form.

Class

views_fields_on_off_form
Provides a handler that adds the form for Fields On/Off.

Code

function options_form(&$form, &$form_state) {
  $all_fields = $this
    ->get_field_labels_no_relationship_names($this->view->display_handler);

  // Remove any field that have been excluded from the display from the list.
  foreach ($all_fields as $key => $field) {
    $exclude = $this->view->display_handler->handlers['field'][$key]->options['exclude'];
    if ($exclude) {
      unset($all_fields[$key]);
    }
  }

  // Offer to include only those fields that follow this one.
  $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
  $form['fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Fields'),
    '#description' => t('Fields to be turned on and off.'),
    '#options' => $field_options,
    '#default_value' => $this->options['fields'],
  );
}