You are here

function FacetapiAjaxWidgetCheckboxes::settingsForm in Ajax facets 7.2

Same name and namespace in other branches
  1. 7.3 plugins/facetapi/ajax_widget_checkboxes.inc \FacetapiAjaxWidgetCheckboxes::settingsForm()
  2. 7 plugins/facetapi/ajax_widget_checkboxes.inc \FacetapiAjaxWidgetCheckboxes::settingsForm()

Overrides FacetapiWidget::settingsForm().

Overrides FacetapiAjaxWidget::settingsForm

File

plugins/facetapi/ajax_widget_checkboxes.inc, line 29
The facetapi_links and facetapi_checkbox_links widget plugin classes.

Class

FacetapiAjaxWidgetCheckboxes
Widget that renders facets as a list of clickable links.

Code

function settingsForm(&$form, &$form_state) {
  parent::settingsForm($form, $form_state);
  if ($this->facet['hierarchy callback']) {
    $form['widget']['widget_settings']['links'][$this->id]['show_expanded'] = array(
      '#type' => 'checkbox',
      '#title' => t('Expand hierarchy'),
      '#default_value' => !empty($this->settings->settings['show_expanded']),
      '#description' => t('Show the entire tree regardless of whether the parent items are active.'),
      '#states' => array(
        'visible' => array(
          'select[name="widget"]' => array(
            'value' => $this->id,
          ),
        ),
      ),
    );
  }
  $form['widget']['widget_settings']['links'][$this->id]['soft_limit'] = array(
    '#type' => 'select',
    '#title' => t('Soft limit'),
    '#default_value' => $this->settings->settings['soft_limit'],
    '#options' => array(
      0 => t('No limit'),
    ) + drupal_map_assoc(array(
      50,
      40,
      30,
      20,
      15,
      10,
      5,
      3,
    )),
    '#description' => t('Limits the number of displayed facets via JavaScript.'),
    '#states' => array(
      'visible' => array(
        'select[name="widget"]' => array(
          'value' => $this->id,
        ),
      ),
    ),
  );
  $last = end($form['widget']['widget_settings']['links']);
  foreach ($form['widget']['widget_settings']['links'] as $id => $element) {
    if ($last != $element) {
      $form['widget']['widget_settings']['links'][$id]['#attributes']['style'] = 'display: none;';
    }
  }
}