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.
}
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,
$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;
}
}
}
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;
+}
+