You are here

function FacetapiAjaxWidgetCheckboxes::settingsForm in Ajax facets 7.3

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

Overrides FacetapiWidget::settingsForm().

Overrides FacetapiAjaxWidget::settingsForm

File

plugins/facetapi/ajax_widget_checkboxes.inc, line 19
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'] = [
      '#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' => [
        'visible' => [
          'select[name="widget"]' => [
            'value' => $this->id,
          ],
        ],
      ],
    ];
  }
  $form['widget']['widget_settings']['links'][$this->id]['soft_limit'] = [
    '#type' => 'select',
    '#title' => t('Soft limit'),
    '#default_value' => $this->settings->settings['soft_limit'],
    '#options' => [
      0 => t('No limit'),
    ] + drupal_map_assoc([
      50,
      40,
      30,
      20,
      15,
      10,
      5,
      3,
    ]),
    '#description' => t('Limits the number of displayed facets via JavaScript.'),
    '#states' => [
      'visible' => [
        'select[name="widget"]' => [
          '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;';
    }
  }
}