summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--handlers/views_handler_filter_in_operator.inc24
-rw-r--r--includes/form.inc17
3 files changed, 32 insertions, 10 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 522934d..39403c1 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -47,6 +47,7 @@ Views 2.x-dev
o #561892 by dereine: Unchecking "rewrite this field" but leaving a value caused field to be rewritten anyway.
o #408894 by dereine: Views AJAX incorrectly used "access content" permission.
o #574150 by dereine: Remove user search because user.module does not store user keywords.
+ o #511908 by dww: Too many check plains in selects because of problems with checkboxes.
Other changes:
o Implement a post_render hook (for themes too) and cache method.
diff --git a/handlers/views_handler_filter_in_operator.inc b/handlers/views_handler_filter_in_operator.inc
index 014afa2..1dd81f0 100644
--- a/handlers/views_handler_filter_in_operator.inc
+++ b/handlers/views_handler_filter_in_operator.inc
@@ -173,11 +173,6 @@ class views_handler_filter_in_operator extends views_handler_filter {
}
if ($which == 'all' || $which == 'value') {
- if ($this->value_form_type == 'checkboxes') {
- foreach ($options as $key => $option) {
- $options[$key] = check_plain($option);
- }
- }
$form['value'] = array(
'#type' => $this->value_form_type,
'#title' => $this->value_title,
@@ -191,18 +186,27 @@ class views_handler_filter_in_operator extends views_handler_filter {
$form_state['input'][$identifier] = $default_value;
}
+ $process = array();
+ if ($this->value_form_type == 'checkboxes') {
+ // If this form element will use checkboxes in the UI, we need to
+ // check_plain() all the options ourselves since FAPI is inconsistent
+ // about this. However, instead of directly doing that to the #options
+ // right now, we define a #process callback since we might change our
+ // mind later and convert this into a 'select' form element, which
+ // would lead to double-escaping the options.
+ $process[] = 'views_process_check_options';
+ }
if ($which == 'all') {
- $process = array();
if (empty($form_state['exposed']) && ($this->value_form_type == 'checkboxes' || $this->value_form_type == 'radios')) {
$process[] = "expand_$this->value_form_type";
$form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
$form['value']['#suffix'] = '</div>';
}
$process[] = 'views_process_dependency';
- $form['value'] += array(
- '#process' => $process,
- '#dependency' => array($source => $this->operator_values(1)),
- );
+ $form['value']['#dependency'] = array($source => $this->operator_values(1));
+ }
+ if (!empty($process)) {
+ $form['value']['#process'] = $process;
}
}
}
diff --git a/includes/form.inc b/includes/form.inc
index 4ecded1..b370d4d 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -280,3 +280,20 @@ function views_process_dependency($element, $edit, &$form_state, &$form) {
return $element;
}
+
+/**
+ * #process callback to see if we need to check_plain() the options.
+ *
+ * Since FAPI is inconsistent, the #options are sanitized for you in all cases
+ * _except_ checkboxes. We have form elements that are sometimes 'select' and
+ * sometimes 'checkboxes', so we need decide late in the form rendering cycle
+ * if the options need to be sanitized before they're rendered. This callback
+ * inspects the type, and if it's still 'checkboxes', does the sanitation.
+ */
+function views_process_check_options($element, $edit, &$form_state, &$form) {
+ if ($element['#type'] == 'checkboxes' || $element['#type'] == 'checkbox') {
+ $element['#options'] = array_map('check_plain', $element['#options']);
+ }
+ return $element;
+}
+