Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
better_exposed_filters
Commits
80233c4b
Commit
80233c4b
authored
Jul 05, 2017
by
Mike Keran
Browse files
Issue #2846909 by mikeker, Gravypower: Placeholder support
parent
87218a29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
config/schema/better_exposed_filters.exposed_form.schema.yml
config/schema/better_exposed_filters.exposed_form.schema.yml
+3
-0
src/Plugin/views/exposed_form/BetterExposedFilters.php
src/Plugin/views/exposed_form/BetterExposedFilters.php
+18
-0
No files found.
config/schema/better_exposed_filters.exposed_form.schema.yml
View file @
80233c4b
...
...
@@ -61,6 +61,9 @@ better_exposed_filters.*:
label
:
'
More
options'
type
:
mapping
mapping
:
placeholder_text
:
type
:
text
label
:
'
Placeholder
text
for
text
fields'
bef_select_all_none
:
type
:
boolean
label
:
'
Add
select
all/none
links'
...
...
src/Plugin/views/exposed_form/BetterExposedFilters.php
View file @
80233c4b
...
...
@@ -509,6 +509,16 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
'#description'
=>
$this
->
t
(
'Places this element in the secondary options portion of the exposed form.'
),
);
if
(
$filter
instanceof
StringFilter
)
{
// Allow users to specify placeholder text.
$bef_options
[
$label
][
'more_options'
][
'placeholder_text'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'Placeholder text'
),
'#description'
=>
$this
->
t
(
'Text to be shown in the text field until it is edited. Leave blank for no placeholder to be set.'
),
'#default_value'
=>
$existing
[
$label
][
'more_options'
][
'placeholder_text'
],
];
}
// Allow rewriting of filter options for any filter. String and numeric
// filters allow unlimited filter options via textfields, so we can't
// offer rewriting for those.
...
...
@@ -855,6 +865,12 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
// configurable.
$field_id
=
$filters
[
$label
]
->
options
[
'expose'
][
'identifier'
];
// Check for placeholder text.
if
(
!
empty
(
$settings
[
$label
][
'more_options'
][
'placeholder_text'
]))
{
// @todo: Add token replacement for placeholder text.
$form
[
$label
][
'#placeholder'
]
=
$settings
[
$label
][
'more_options'
][
'placeholder_text'
];
}
// Handle filter value rewrites.
if
(
!
empty
(
$options
[
'more_options'
][
'rewrite'
][
'filter_rewrite_values'
]))
{
$form
[
$field_id
][
'#options'
]
=
$this
->
rewriteOptions
(
$form
[
$field_id
][
'#options'
]
,
$options
[
'more_options'
][
'rewrite'
][
'filter_rewrite_values'
]);
...
...
@@ -1490,6 +1506,7 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
$filter_defaults
=
array
(
'bef_format'
=>
'default'
,
'more_options'
=>
array
(
'placeholder_text'
=>
''
,
'bef_select_all_none'
=>
FALSE
,
'bef_select_all_none_nested'
=>
FALSE
,
'bef_collapsible'
=>
FALSE
,
...
...
@@ -1524,4 +1541,5 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
}
return
$settings
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment