Commit b03efbf5 authored by catch's avatar catch
Browse files

Issue #1785318 by peterpoe, dawehner, dagmar, damiankloip: Fixed Grouped...

Issue #1785318 by peterpoe, dawehner, dagmar, damiankloip: Fixed Grouped filter doesn't allow you to use fields without a value.
parent e28f1738
...@@ -635,11 +635,13 @@ function build_group_validate($form, &$form_state) { ...@@ -635,11 +635,13 @@ function build_group_validate($form, &$form_state) {
} }
if (!empty($form_state['values']['options']['group_info']['group_items'])) { if (!empty($form_state['values']['options']['group_info']['group_items'])) {
$operators = $this->operators();
foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) { foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
if (empty($group['remove'])) { if (empty($group['remove'])) {
// Check if the title is defined but value wasn't defined. // Check if the title is defined but value wasn't defined.
if (!empty($group['title'])) { if (!empty($group['title']) && $operators[$group['operator']]['values'] > 0) {
if ((!is_array($group['value']) && trim($group['value']) == "") || if ((!is_array($group['value']) && trim($group['value']) == "") ||
(is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) == 0)) { (is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) == 0)) {
form_error($form['group_info']['group_items'][$id]['value'], form_error($form['group_info']['group_items'][$id]['value'],
......
...@@ -180,6 +180,17 @@ function testExposedAdminUi() { ...@@ -180,6 +180,17 @@ function testExposedAdminUi() {
$edit["options[group_info][group_items][3][value][page]"] = TRUE; $edit["options[group_info][group_items][3][value][page]"] = TRUE;
$this->drupalPost(NULL, $edit, t('Apply')); $this->drupalPost(NULL, $edit, t('Apply'));
// Select the empty operator, so the empty value should not trigger a form
// error.
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/body_value');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = $this->randomName();
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPost(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'Validation did not run for the empty operator.');
// Test the validation error message text is not shown.
$this->assertNoText(t('The value is required if title for this item is defined.'));
// Validate that all the titles are defined for each group // Validate that all the titles are defined for each group
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
$edit = array(); $edit = array();
......
...@@ -23,6 +23,46 @@ display: ...@@ -23,6 +23,46 @@ display:
id: type id: type
table: node table: node
plugin_id: node_type plugin_id: node_type
body_value:
id: body_value
table: field_data_body
field: body_value
relationship: none
group_type: group
admin_label: ''
operator: '='
value: ''
group: '1'
exposed: '1'
expose:
operator_id: body_value_op
label: 'Body (body)'
description: ''
use_operator: '0'
operator: body_value_op
identifier: body_value
required: '0'
remember: '0'
multiple: '0'
remember_roles:
authenticated: authenticated
is_grouped: '1'
group_info:
label: 'Body (body)'
description: ''
identifier: body_value
optional: '1'
widget: select
multiple: '0'
remember: '0'
default_group: All
default_group_multiple: { }
group_items:
1:
title: Test
operator: empty
value: ''
plugin_id: string
pager: pager:
type: full type: full
sorts: sorts:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment