diff --git a/lib/classes/sidebar/OptionsWidget.php b/lib/classes/sidebar/OptionsWidget.php index 32aab516d24c22853d5d214919e8668beb5a1836..99efc8ac720bf876335b6dd40e796f6cd8c1bc16 100644 --- a/lib/classes/sidebar/OptionsWidget.php +++ b/lib/classes/sidebar/OptionsWidget.php @@ -75,20 +75,26 @@ class OptionsWidget extends ListWidget */ public function addSelect($label, $url, $name, $options, $selected_option = false, $attributes = []) { - $widget = new SelectWidget($label, $url, $name); - $widget->layout = false; + $option_content = ''; - foreach ($options as $value => $option_label) { - $widget->addElement(new SelectElement($value, $option_label, $value === $selected_option)); + foreach ($options as $value => $option) { + $selected = $value === $selected_option ? 'selected' : ''; + $option_content .= sprintf( + '<option value="%s" %s>%s</option>', + htmlReady($value), + $selected, + htmlReady($option) + ); } - if (isset($widget->attributes) && is_array($widget->attributes)) { - $widget->attributes = array_merge($widget->attributes, $attributes); - } else { - $widget->attributes = $attributes; - } - - $content = $widget->render(); + $content = sprintf( + '<select data-formaction="%s" class="sidebar-selectlist submit-upon-select" name="%s" aria-label="%s" %s>%s</select>', + htmlReady($url), + htmlReady($name), + htmlReady($label), + arrayToHtmlAttributes($attributes), + $option_content + ); $this->addElement(new WidgetElement($content)); } diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js index 1f8b86452e778a7446a0d1347ed3c30efebf97bf..781faac0e3a784f4c27e9124e68ee915c33e8dcc 100644 --- a/resources/assets/javascripts/bootstrap/forms.js +++ b/resources/assets/javascripts/bootstrap/forms.js @@ -107,6 +107,9 @@ $(document) // Submit only if value has changed and either enter was pressed or // select was opened by click if (!is_default && shouldSubmit) { + if ($(this).data('formaction')) { + $(this.form).attr('action', $(this).data('formaction')); + } $(this.form).submit(); return false; }