You are here

function views_handler_argument::default_argument_form in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 handlers/views_handler_argument.inc \views_handler_argument::default_argument_form()
  2. 7.3 handlers/views_handler_argument.inc \views_handler_argument::default_argument_form()

Provide a form for selecting the default argument when the default action is set to provide default argument.

1 call to views_handler_argument::default_argument_form()
views_handler_argument_date::default_argument_form in handlers/views_handler_argument_date.inc
Add an option to set the default value to the current date.
1 method overrides views_handler_argument::default_argument_form()
views_handler_argument_date::default_argument_form in handlers/views_handler_argument_date.inc
Add an option to set the default value to the current date.

File

handlers/views_handler_argument.inc, line 308

Class

views_handler_argument
Base class for arguments.

Code

function default_argument_form(&$form, &$form_state) {
  $plugins = views_fetch_plugin_data('argument default');
  $options = array();

  // This construct uses 'hidden' and not markup because process doesn't
  // run. It also has an extra div because the dependency wants to hide
  // the parent in situations like this, so we need a second div to
  // make this work.
  $form['default_options_div_prefix'] = array(
    '#type' => 'hidden',
    '#id' => 'views-default-options',
    '#prefix' => '<div><fieldset id="views-default-options"><legend>' . t('Provide default argument options') . '</legend>',
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'radio:options[default_action]' => array(
        'default',
      ),
    ),
  );
  $form['default_argument_type'] = array(
    '#prefix' => '<div id="edit-options-default-argument-type-wrapper">',
    '#suffix' => '</div>',
    '#type' => 'radios',
    '#id' => 'edit-options-default-argument-type',
    '#title' => t('Default argument type'),
    '#default_value' => $this->options['default_argument_type'],
    '#process' => array(
      'expand_radios',
      'views_process_dependency',
    ),
    '#dependency' => array(
      'radio:options[default_action]' => array(
        'default',
      ),
    ),
  );
  foreach ($plugins as $id => $info) {
    $plugin = views_get_plugin('argument default', $id);
    if ($plugin) {
      $plugin
        ->init($this->view, $this, $id);
      if ($plugin
        ->access() || $this->options['default_argument_type'] == $id) {
        $options[$id] = $info['title'];
        $plugin
          ->argument_form($form, $form_state);
      }
    }
  }
  $form['default_options_div_suffix'] = array(
    '#value' => '</fieldset></div>',
  );
  asort($options);
  $form['default_argument_type']['#options'] = $options;
}