public function ArgumentPluginBase::defaultArgumentForm

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

1 call to ArgumentPluginBase::defaultArgumentForm()
Date::defaultArgumentForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php
Add an option to set the default value to the current date.
1 method overrides ArgumentPluginBase::defaultArgumentForm()
Date::defaultArgumentForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php
Add an option to set the default value to the current date.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php, line 500
Definition of Drupal\views\Plugin\views\argument\ArgumentPluginBase.

Class

ArgumentPluginBase
Base class for arguments.

Namespace

Drupal\views\Plugin\views\argument

Code

public function defaultArgumentForm(&$form, &$form_state) {
  $plugins = Views::pluginManager('argument_default')
    ->getDefinitions();
  $options = array();
  $form['default_argument_skip_url'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip default argument for view URL'),
    '#default_value' => $this->options['default_argument_skip_url'],
    '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.'),
  );
  $form['default_argument_type'] = array(
    '#prefix' => '<div id="edit-options-default-argument-type-wrapper">',
    '#suffix' => '</div>',
    '#type' => 'select',
    '#id' => 'edit-options-default-argument-type',
    '#title' => t('Type'),
    '#default_value' => $this->options['default_argument_type'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[default_action]"]' => array(
          'value' => 'default',
        ),
      ),
    ),
    // Views custom key, moves this element to the appropriate container
    // under the radio button.
    '#argument_option' => 'default',
  );
  foreach ($plugins as $id => $info) {
    if (!empty($info['no_ui'])) {
      continue;
    }
    $plugin = $this
      ->getPlugin('argument_default', $id);
    if ($plugin) {
      if ($plugin
        ->access() || $this->options['default_argument_type'] == $id) {
        $form['argument_default']['#argument_option'] = 'default';
        $form['argument_default'][$id] = array(
          '#prefix' => '<div id="edit-options-argument-default-options-' . $id . '-wrapper">',
          '#suffix' => '</div>',
          '#id' => 'edit-options-argument-default-options-' . $id,
          '#type' => 'item',
          // Even if the plugin has no options add the key to the form_state.
          '#input' => TRUE,
          '#states' => array(
            'visible' => array(
              ':input[name="options[default_action]"]' => array(
                'value' => 'default',
              ),
              ':input[name="options[default_argument_type]"]' => array(
                'value' => $id,
              ),
            ),
          ),
          '#default_value' => array(),
        );
        $options[$id] = $info['title'];
        $plugin
          ->buildOptionsForm($form['argument_default'][$id], $form_state);
      }
    }
  }
  asort($options);
  $form['default_argument_type']['#options'] = $options;
}