You are here

function SearchApiRangesWidgetUISlider::settingsForm in Search API ranges 7

Allows the widget to provide additional settings to the form.

File

plugins/facetapi/widget_slider.inc, line 48
Widget for facets rendered as UI slider with Min/Max.

Class

SearchApiRangesWidgetUISlider
@file Widget for facets rendered as UI slider with Min/Max.

Code

function settingsForm(&$form, &$form_state) {
  $form['widget']['widget_settings']['links'][$this->id]['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $this->settings->settings['name'],
    '#description' => t('The name of the range field.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['prefix'] = array(
    '#type' => 'textfield',
    '#title' => t('Prefix'),
    '#default_value' => $this->settings->settings['prefix'],
    '#description' => t('Adds a prefix to the slider, e.g. $, #.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['suffix'] = array(
    '#type' => 'textfield',
    '#title' => t('Suffix'),
    '#default_value' => $this->settings->settings['suffix'],
    '#description' => t('Adds a suffix to the slider, e.g. €, pcs., etc.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['auto-submit-delay'] = array(
    '#type' => 'textfield',
    '#title' => t('Auto Submit Delay'),
    '#default_value' => $this->settings->settings['auto-submit-delay'],
    '#description' => t('Automatically submit form after the user changes
        releases slider handles. Enter a delay in milliseconds,
        i.e. 1000 for 1 second.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['slider-step'] = array(
    '#type' => 'textfield',
    '#title' => t('Step for the slider'),
    '#default_value' => is_numeric($this->settings->settings['slider-step']) ? $this->settings->settings['slider-step'] : 1,
    '#description' => t('Default is 1. Can be decimal: 0.1, 0.5 and so on. Use point as delimeter in decimals. From jQuery UI API documentation: Determines the size or amount of each interval or step the slider takes between the min and max. The full specified value range of the slider (max - min) should be evenly divisible by the step.'),
    //'#states' => array('invisible' => array( ':input[name="use-decimals"]' => array('checked' => FALSE),),),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['round-precision'] = array(
    '#type' => 'textfield',
    '#title' => t('Round precision'),
    '#default_value' => is_numeric($this->settings->settings['round-precision']) ? (int) $this->settings->settings['round-precision'] : 0,
    '#description' => t('Specifies the number of decimal digits to round to. Default is 0. Can be only integer number.'),
    //'#states' => array('invisible' => array( ':input[name="use-decimals"]' => array('checked' => FALSE),),),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
}