You are here

function SearchApiRangesWidgetSelect::settingsForm in Search API ranges 7

Allows the widget to provide additional settings to the form.

File

plugins/facetapi/widget_select.inc, line 102
Widget for facet ranges rendered as text links.

Class

SearchApiRangesWidgetSelect
@file Widget for facet ranges rendered as text links.

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,
        ),
      ),
      'enabled' => 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 text links, e.g. $, #.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
      'enabled' => 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 text links, e.g. €, pcs., etc.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
      'enabled' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['range_simple'] = array(
    '#type' => 'textfield',
    '#title' => t('Simple range'),
    '#default_value' => $this->settings->settings['range_simple'],
    '#description' => t('Add a fixed range to create "range facet".
        For example, "10" on a price field will create 10 - 20, 20 - 30 etc.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
      'enabled' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $form['widget']['widget_settings']['links'][$this->id]['range_advanced'] = array(
    '#type' => 'textarea',
    '#title' => t('Advanced range'),
    '#default_value' => $this->settings->settings['range_advanced'],
    '#description' => t('Add a pre-defined list of ranges to create
        "range facets". For examples, refer to README in search api range.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
      'enabled' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
}