Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
better_exposed_filters
Commits
a842c6e2
Commit
a842c6e2
authored
Jul 20, 2012
by
Mike Keran
Browse files
Issue #1171952 by primerg: Add single on/off checkbox option for yes/no filters
parent
3a78e5d9
Changes
2
Show whitespace changes
Inline
Side-by-side
CHANGELOG.txt
View file @
a842c6e2
...
...
@@ -6,6 +6,7 @@ Better Exposed Filters 6.x-2.0-xxxx xxxx-xx-xx
------------------------------------------------
Issue #1291994 by ressa: Adds node counts to taxonomy filters.
by mikeker: Added term depth limit option.
Issue #1171952 by primerg: Add single on/off checkbox option for yes/no filters
Better Exposed Filters 6.x-2.0-beta2 2011-08-03
...
...
better_exposed_filters.module
View file @
a842c6e2
...
...
@@ -88,6 +88,13 @@ function better_exposed_filters_form_alter(&$form, $form_state, $form_id) {
),
);
if
(
$form
[
'options'
][
'value'
][
'#type'
]
==
'radios'
&&
count
(
$form
[
'options'
][
'value'
][
'#options'
])
==
3
&&
isset
(
$form
[
'options'
][
'value'
][
'#options'
][
1
])
&&
isset
(
$form
[
'options'
][
'value'
][
'#options'
][
0
]))
{
$left
[
'bef_format'
][
'#options'
][
'bef_single'
]
=
t
(
'Single on/off checkbox'
);
}
// Build check all/none option form element
$right
[
'bef_select_all_none'
]
=
array
(
'#type'
=>
'checkbox'
,
...
...
@@ -219,12 +226,30 @@ function better_exposed_filters_form_alter(&$form, $form_state, $form_id) {
// Intentionally falling through
case
'bef'
:
case
'bef_single'
:
$show_apply
=
TRUE
;
if
(
empty
(
$form
[
$field_id
][
'#multiple'
]))
{
// Single-select -- display as radio buttons
$form
[
$field_id
][
'#type'
]
=
'radios'
;
$form
[
$field_id
][
'#process'
]
=
array
(
'expand_radios'
,
'views_process_dependency'
);
// Use the single checkbox
if
(
$filter
->
options
[
'expose'
][
'bef_format'
]
==
'bef_single'
)
{
$form
[
$field_id
][
'#type'
]
=
'checkbox'
;
$form
[
$field_id
][
'#title'
]
=
$form
[
'#info'
][
"filter-
$field_id
"
][
'label'
];
// Remove this option. We only need the values 1 and 0
unset
(
$form
[
$field_id
][
'#options'
][
'All'
]);
// Drupal core has a bug dealing with type checkbox. This is a
// fix to make sure the checkboxes are on and off based on user
// selection
if
(
$form_state
[
'input'
][
$field_id
]
==
'All'
)
{
$form
[
$field_id
][
'#default_value'
]
=
0
;
$form_state
[
'input'
][
$field_id
]
=
0
;
}
$form
[
$field_id
][
'#value'
]
=
$form_state
[
'input'
][
$field_id
];
}
// Clean up objects from the options array (happens for taxonomy-based filters)
$options
=
$form
[
$field_id
][
'#options'
];
$form
[
$field_id
][
'#options'
]
=
array
();
...
...
Write
Preview
Supports
Markdown
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