diff --git a/src/Plugin/views/exposed_form/BetterExposedFilters.php b/src/Plugin/views/exposed_form/BetterExposedFilters.php index bcccd50..3c48219 100644 --- a/src/Plugin/views/exposed_form/BetterExposedFilters.php +++ b/src/Plugin/views/exposed_form/BetterExposedFilters.php @@ -162,7 +162,7 @@ class BetterExposedFilters extends InputRequired { '#type' => 'checkbox', '#title' => $this->t('Combine sort order with sort by'), '#default_value' => $existing['sort']['advanced']['combine'], - '#description' => $this->t('Combines the sort by options and order (ascending or decending) into a single list. Use this to display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)" in a single form element.'), + '#description' => $this->t('Combines the sort by options and order (ascending or decending) into a single list. Use this to display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)" in a single form element. Sort order should first be exposed by selecting Allow people to choose the sort order.'), ); $bef_options['sort']['advanced']['combine_rewrite'] = array( '#type' => 'textarea', @@ -636,7 +636,7 @@ Off|No /* * Handle exposed sort elements. */ - if (isset($settings['sort']) && !empty($form['sort_by']) && !empty($form['sort_order'])) { + if (isset($settings['sort']) && !empty($form['sort_by'])) { $show_apply = TRUE; // If selected, collect all sort-related form elements and put them @@ -646,7 +646,7 @@ Off|No $sort_elems = array(); // Check for combined sort_by and sort_order. - if ($settings['sort']['advanced']['combine']) { + if ($settings['sort']['advanced']['combine'] && !empty($form['sort_order'])) { $options = []; // Add reset sort option at the top of the list. @@ -741,19 +741,25 @@ Off|No } elseif ('bef_links' == $settings['sort']['bef_format']) { $form['sort_by']['#theme'] = 'bef_links'; - $form['sort_order']['#theme'] = 'bef_links'; + if(!empty($form['sort_order'])) { + $form['sort_order']['#theme'] = 'bef_links'; + } // Exposed form displayed as blocks can appear on pages other than the // view results appear on. This can cause problems with // select_as_links options as they will use the wrong path. We provide // a hint for theme functions to correct this. $form['sort_by']['#bef_path'] = $this->displayHandler->getUrl(); - $form['sort_order']['#bef_path'] = $this->displayHandler->getUrl(); + if(!empty($form['sort_order'])) { + $form['sort_order']['#bef_path'] = $this->displayHandler->getUrl(); + } } if ($collapse) { $sort_elems[] = 'sort_by'; - $sort_elems[] = 'sort_order'; + if(!empty($form['sort_order'])) { + $sort_elems[] = 'sort_order'; + } } // Add reset sort option if selected.