Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
d1db5741
Commit
d1db5741
authored
12 years ago
by
Tim Plunkett
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1719496
by dagmar: Fixed Filter cannot be configured after certain conditions.
parent
5e4b5ff6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
+11
-9
11 additions, 9 deletions
lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
lib/Drupal/views/Tests/ExposedFormTest.php
+31
-0
31 additions, 0 deletions
lib/Drupal/views/Tests/ExposedFormTest.php
with
42 additions
and
9 deletions
lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
+
11
−
9
View file @
d1db5741
...
@@ -184,7 +184,7 @@ function can_build_group() {
...
@@ -184,7 +184,7 @@ function can_build_group() {
* Returns TRUE if the exposed filter works like a grouped filter.
* Returns TRUE if the exposed filter works like a grouped filter.
*/
*/
function
is_a_group
()
{
function
is_a_group
()
{
return
!
empty
(
$this
->
options
[
'is_grouped'
]);
return
$this
->
is_exposed
()
&&
!
empty
(
$this
->
options
[
'is_grouped'
]);
}
}
/**
/**
...
@@ -597,16 +597,18 @@ function expose_validate($form, &$form_state) {
...
@@ -597,16 +597,18 @@ function expose_validate($form, &$form_state) {
* Validate the build group options form.
* Validate the build group options form.
*/
*/
function
build_group_validate
(
$form
,
&
$form_state
)
{
function
build_group_validate
(
$form
,
&
$form_state
)
{
if
(
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]))
{
if
(
!
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
]))
{
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'The identifier is required if the filter is exposed.'
));
if
(
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]))
{
}
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'The identifier is required if the filter is exposed.'
));
}
if
(
!
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
])
&&
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]
==
'value'
)
{
if
(
!
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
])
&&
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]
==
'value'
)
{
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'This identifier is not allowed.'
));
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'This identifier is not allowed.'
));
}
}
if
(
!
$this
->
view
->
display_handler
->
is_identifier_unique
(
$form_state
[
'id'
],
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]))
{
if
(
!
$this
->
view
->
display_handler
->
is_identifier_unique
(
$form_state
[
'id'
],
$form_state
[
'values'
][
'options'
][
'group_info'
][
'identifier'
]))
{
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'This identifier is used by another handler.'
));
form_error
(
$form
[
'group_info'
][
'identifier'
],
t
(
'This identifier is used by another handler.'
));
}
}
}
if
(
!
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'group_items'
]))
{
if
(
!
empty
(
$form_state
[
'values'
][
'options'
][
'group_info'
][
'group_items'
]))
{
...
...
This diff is collapsed.
Click to expand it.
lib/Drupal/views/Tests/ExposedFormTest.php
+
31
−
0
View file @
d1db5741
...
@@ -65,6 +65,13 @@ function testExposedAdminUi() {
...
@@ -65,6 +65,13 @@ function testExposedAdminUi() {
// Be sure that the button is called exposed.
// Be sure that the button is called exposed.
$this
->
helperButtonHasLabel
(
'edit-options-expose-button-button'
,
t
(
'Expose filter'
));
$this
->
helperButtonHasLabel
(
'edit-options-expose-button-button'
,
t
(
'Expose filter'
));
// The first time the filter UI is displayed, the operator and the
// value forms should be shown.
$this
->
assertFieldById
(
'edit-options-operator-in'
,
''
,
'Operator In exists'
);
$this
->
assertFieldById
(
'edit-options-operator-not-in'
,
''
,
'Operator Not In exists'
);
$this
->
assertFieldById
(
'edit-options-value-page'
,
''
,
'Checkbox for Page exists'
);
$this
->
assertFieldById
(
'edit-options-value-article'
,
''
,
'Checkbox for Article exists'
);
// Click the Expose filter button.
// Click the Expose filter button.
$this
->
drupalPost
(
'admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'
,
$edit
,
t
(
'Expose filter'
));
$this
->
drupalPost
(
'admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'
,
$edit
,
t
(
'Expose filter'
));
// Check the label of the expose button.
// Check the label of the expose button.
...
@@ -72,6 +79,12 @@ function testExposedAdminUi() {
...
@@ -72,6 +79,12 @@ function testExposedAdminUi() {
// Check the label of the grouped exposed button
// Check the label of the grouped exposed button
$this
->
helperButtonHasLabel
(
'edit-options-group-button-button'
,
t
(
'Grouped filters'
));
$this
->
helperButtonHasLabel
(
'edit-options-group-button-button'
,
t
(
'Grouped filters'
));
// After exposing the filter, Operator and Value should be still here.
$this
->
assertFieldById
(
'edit-options-operator-in'
,
''
,
'Operator In exists'
);
$this
->
assertFieldById
(
'edit-options-operator-not-in'
,
''
,
'Operator Not In exists'
);
$this
->
assertFieldById
(
'edit-options-value-page'
,
''
,
'Checkbox for Page exists'
);
$this
->
assertFieldById
(
'edit-options-value-article'
,
''
,
'Checkbox for Article exists'
);
// Check the validations of the filter handler.
// Check the validations of the filter handler.
$edit
=
array
();
$edit
=
array
();
$edit
[
'options[expose][identifier]'
]
=
''
;
$edit
[
'options[expose][identifier]'
]
=
''
;
...
@@ -91,6 +104,14 @@ function testExposedAdminUi() {
...
@@ -91,6 +104,14 @@ function testExposedAdminUi() {
// Click the Grouped Filters button.
// Click the Grouped Filters button.
$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'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Grouped filters'
));
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Grouped filters'
));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
$this
->
assertNoFieldById
(
'edit-options-operator-in'
,
''
,
'Operator In not exists'
);
$this
->
assertNoFieldById
(
'edit-options-operator-not-in'
,
''
,
'Operator Not In not exists'
);
$this
->
assertNoFieldById
(
'edit-options-value-page'
,
''
,
'Checkbox for Page not exists'
);
$this
->
assertNoFieldById
(
'edit-options-value-article'
,
''
,
'Checkbox for Article not exists'
);
// Check that after click on 'Grouped Filters', a new button is shown to
// Check that after click on 'Grouped Filters', a new button is shown to
// add more items to the list.
// add more items to the list.
$this
->
helperButtonHasLabel
(
'edit-options-group-info-add-group'
,
t
(
'Add another item'
));
$this
->
helperButtonHasLabel
(
'edit-options-group-info-add-group'
,
t
(
'Add another item'
));
...
@@ -125,6 +146,16 @@ function testExposedAdminUi() {
...
@@ -125,6 +146,16 @@ function testExposedAdminUi() {
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'Apply'
));
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'Apply'
));
$this
->
assertRaw
(
t
(
'The title is required if value for this item is defined.'
),
t
(
'Group items should have a title'
));
$this
->
assertRaw
(
t
(
'The title is required if value for this item is defined.'
),
t
(
'Group items should have a title'
));
// Un-expose the filter.
$this
->
drupalGet
(
'admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Hide filter'
));
// After Un-exposing the filter, Operator and Value should be shown again.
$this
->
assertFieldById
(
'edit-options-operator-in'
,
''
,
'Operator In exists after hide filter'
);
$this
->
assertFieldById
(
'edit-options-operator-not-in'
,
''
,
'Operator Not In exists after hide filter'
);
$this
->
assertFieldById
(
'edit-options-value-page'
,
''
,
'Checkbox for Page exists after hide filter'
);
$this
->
assertFieldById
(
'edit-options-value-article'
,
''
,
'Checkbox for Article exists after hide filter'
);
// Click the Expose sort button.
// Click the Expose sort button.
$edit
=
array
();
$edit
=
array
();
$this
->
drupalPost
(
'admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created'
,
$edit
,
t
(
'Expose sort'
));
$this
->
drupalPost
(
'admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created'
,
$edit
,
t
(
'Expose sort'
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment