function bef_checkbox in Better Exposed Filters 6
Same name and namespace in other branches
- 8.3 better_exposed_filters.theme \bef_checkbox()
- 6.3 better_exposed_filters.theme \bef_checkbox()
- 6.2 better_exposed_filters.theme \bef_checkbox()
- 7 better_exposed_filters.theme \bef_checkbox()
Build a BEF checkbox -- very similar to theme_checkbox (http://api.drupal.org/api/function/theme_checkbox/6)
Parameters
$element - array: original <select> element generated by Views:
$value - string: value of this checkbox option:
$label - string: label for this checkbox option:
$selected - bool: checked or not:
Return value
string: checkbox HTML
2 calls to bef_checkbox()
- theme_select_as_checkboxes in ./
better_exposed_filters.theme - Themes a select element as a set of checkboxes
- theme_select_as_tree in ./
better_exposed_filters.theme - Themes a taxonomy-based exposed filter select element as a nested unordered list. Note: this routine depends on the '-' char prefixed on the term names by Views to determine depth.
File
- ./
better_exposed_filters.theme, line 372
Code
function bef_checkbox($element, $value, $label, $selected) {
$value = check_plain($value);
$label = check_plain($label);
$id = form_clean_id($element['#id'] . '-' . $value);
// Custom ID for each checkbox based on the <select>'s original ID
$properties = array(
'#required' => FALSE,
'#id' => $id,
);
$checkbox = '<input type="checkbox" ' . 'name="' . $element['#name'] . '[]" ' . 'id="' . $id . '" ' . 'value="' . $value . '" ' . ($selected ? 'checked="checked" ' : '') . drupal_attributes($element['#attributes']) . ' />';
$item = "{$checkbox} <label class='option' for='{$id}'>{$label}</label>";
$output .= theme('form_element', $properties, $item);
return $output;
}