diff --git a/core/modules/views/css/views.exposed_form.css b/core/modules/views/css/views.exposed_form.css new file mode 100644 index 0000000000000000000000000000000000000000..273e598e250e117104026667da7967d1a54e6158 --- /dev/null +++ b/core/modules/views/css/views.exposed_form.css @@ -0,0 +1,20 @@ +/** + * @file + * Styling for Views exposed forms. + */ +.views-exposed-form .form-item { + /* Display exposed form elements horizontally. */ + float: left; /* LTR */ + margin-right: .25em; /* LTR */ +} +[dir="rtl"] .views-exposed-form .form-item { + float: right; + margin-left: .25em; +} + +.views-exposed-form .form-actions { + clear: left; /* LTR */ +} +[dir="rtl"] .views-exposed-form .form-actions { + clear: right; +} diff --git a/core/modules/views/css/views.module.css b/core/modules/views/css/views.module.css index e422122cb4e4ba13a99ddc0cfe51b344a945bb13..707b71262514ec140cb90749f18465dd58bf8bd2 100644 --- a/core/modules/views/css/views.module.css +++ b/core/modules/views/css/views.module.css @@ -1,13 +1,3 @@ -.views-exposed-form .views-exposed-widget { - display: inline-block; -} - -.views-exposed-form .form-item, -.views-exposed-form .form-submit { - margin-top: 0; - margin-bottom: 0; -} - /* table style column align */ .views-align-left { text-align: left; diff --git a/core/modules/views/templates/views-exposed-form.html.twig b/core/modules/views/templates/views-exposed-form.html.twig index d4986e6d1e1eb9c95fd56238fa222215a63d471c..5a34f2fc2f96c8f54bfabd5d070621bdde7907f0 100644 --- a/core/modules/views/templates/views-exposed-form.html.twig +++ b/core/modules/views/templates/views-exposed-form.html.twig @@ -4,21 +4,7 @@ * Default theme implementation of a views exposed form. * * Available variables: - * - widgets: A list of exposed form widgets. Each widget contains: - * - label: The sanitized label of the widget. - * - id: The ID of the widget, if available. - * - operator: The select element for the operator widget. - * - description: The sanitized description of the widget. - * - widget: The widget itself. - * - index: the widget's row index. * - form: A render element representing the form. - * - sort_by: An optional select element to sort the view by fields. - * - sort_order: An optional select element with ascending or - * descending order options. - * - items_per_page: An optional select element for the available items per - * page. - * - offset: An optional textfield to define the offset of the view. - * - reset_button: An optional button to reset the exposed filter applied. * * @see template_preprocess_views_exposed_form() * @@ -32,55 +18,6 @@ #} {{ q }} {% endif %} -
-
- {% for index, widget in widgets %} -
- {% if widget.label %} - - {% endif %} - {% if widget.operator %} -
- {{ widget.operator }} -
- {% endif %} -
- {{ widget.widget }} -
- {% if widget.description %} -
- {{ widget.description }} -
- {% endif %} -
- {% endfor %} - {% if form.sort_by %} -
- {{ form.sort_by }} -
-
- {{ form.sort_order }} -
- {% endif %} - {% if form.items_per_page %} -
- {{ form.items_per_page }} -
- {% endif %} - {% if form.offset %} -
- {{ form.offset }} -
- {% endif %} -
- {{ form }} -
- {% if form.reset_button %} -
- {{ form.reset_button }} -
- {% endif %} -
+
+ {{ form }}
diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 5c4bb60af727494eddc9ca746d2cd05f0dd1ea43..7e164f2c8c440d03344b7a8bfda877d68697219b 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -830,6 +830,13 @@ function views_library_info() { array('system', 'drupal'), ), ); + $libraries['views.exposed-form'] = array( + 'title' => 'Views exposed form', + 'version' => VERSION, + 'css' => array( + "$path/css/views.exposed_form.css", + ), + ); return $libraries; } @@ -1351,7 +1358,8 @@ function views_exposed_form($form, &$form_state) { } } - $form['submit'] = array( + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( // Prevent from showing up in $_GET. '#name' => '', '#type' => 'submit', diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 5ee51435aa877a1cbf80d65de6c92d5a20992660..f88413d18185a8d2d17faee7c71c90e7fd9dae31 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -1038,52 +1038,17 @@ function template_preprocess_views_view_row_rss(&$variables) { function template_preprocess_views_exposed_form(&$variables) { $form = &$variables['form']; - // Put all single checkboxes together in the last spot. - $checkboxes = array(); - if (!empty($form['q'])) { $variables['q'] = $form['q']; } - $variables['widgets'] = array(); - foreach ($form['#info'] as $id => $info) { - // Set aside checkboxes. - if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') { - $checkboxes[] = $form[$info['value']]; - continue; - } - $widget = new stdClass(); - // set up defaults so that there's always something there. - $widget->label = $widget->operator = $widget->widget = $widget->description = ''; - - $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : ''; + // Include basic theming for exposed forms. + $form['#attached']['library'][] = array('views', 'views.exposed-form'); + foreach ($form['#info'] as $id => $info) { if (!empty($info['label'])) { - $widget->label = check_plain($info['label']); - } - if (!empty($info['operator']) && isset($form[$info['operator']])) { - $widget->operator = $form[$info['operator']]; + $form[$info['value']]['#title'] = $info['label']; } - - $widget->widget = $form[$info['value']]; - - if (!empty($info['description'])) { - $widget->description = check_plain($info['description']); - } - - $variables['widgets'][$id] = $widget; - // Unset the widget, so that it doesn't get rendered twice. - unset($form[$info['value']]); - } - - // Wrap up all the checkboxes we set aside into a widget. - if (!empty($checkboxes)) { - $widget = new stdClass(); - // set up defaults so that there's always something there. - $widget->label = $widget->operator = $widget->widget = NULL; - $widget->id = 'checkboxes'; - $widget->widget = $checkboxes; - $variables['widgets']['checkboxes'] = $widget; } }