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
89739947
Commit
89739947
authored
Jan 04, 2016
by
chx
Committed by
Mike Keran
Jan 05, 2016
Browse files
Issue #2618500 by chx: Single on/off checkbox is always checked
parent
6a75d4fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
better_exposed_filters_exposed_form_plugin.inc
View file @
89739947
...
...
@@ -1438,7 +1438,27 @@ dateFormat: "dd-mm-yy"
$form
[
$filter_id
][
'#description'
]
=
$options
[
'more_options'
][
'bef_filter_description'
];
$form
[
$filter_id
][
'#return_value'
]
=
1
;
$form
[
$filter_id
][
'#type'
]
=
'checkbox'
;
// Views populates missing values in $form_state['input'] with the
// defaults and a checkbox does not appear in $_GET (or $_POST) so it
// will appear to be missing when a user submits a form. Because of
// this, instead of unchecking the checkbox value will revert to the
// default. More, the default value for select values is reused which
// results in the checkbox always checked. So we need to add a form
// element to see whether the form is submitted or not and then we
// need to look at $_GET directly to see whether the checkbox is
// there. For security reasons, we must not copy the $_GET value.
// First, let's figure out a short name for the signal element and
// then add it.
if
(
empty
(
$signal
))
{
for
(
$signal
=
'a'
;
isset
(
$form
[
$signal
]);
$signal
++
);
// This is all the signal element needs.
$form
[
$signal
][
'#type'
]
=
'hidden'
;
}
$checked
=
isset
(
$form_state
[
'input'
][
$signal
])
?
isset
(
$_GET
[
$filter_id
])
:
$form
[
$filter_id
][
'#default_value'
];
// Now we know whether the checkbox is checked or not, set #value
// accordingly.
$form
[
$filter_id
][
'#value'
]
=
$checked
?
$form
[
$filter_id
][
'#return_value'
]
:
0
;
// Handoff to the theme layer.
$form
[
$filter_id
][
'#theme'
]
=
'checkbox'
;
break
;
...
...
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