1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
FILENAME : includes/form.api
LINE No. 1870
----------------------------------------------------------------------------------------------------
/**
* Format a checkbox.
*
* @param $element
* An associative array containing the properties of the element.
* Properties used: title, value, return_value, description, required
* @return
* A themed HTML string representing the checkbox.
*
* @ingroup themeable
*/
function theme_checkbox($element) {
_form_set_class($element, array('form-checkbox'));
$checkbox = '<input ';
$checkbox .= 'type="checkbox" ';
$checkbox .= 'name="'. $element['#name'] .'" ';
$checkbox .= 'id="'. $element['#id'] .'" ' ;
$checkbox .= 'class="'. $element['#options_class'] . '" '; /************************* CUSTOM CODE BY PRASHANT SHAH *************************/
$checkbox .= 'value="'. $element['#return_value'] .'" ';
$checkbox .= $element['#value'] ? ' checked="checked" ' : ' ';
$checkbox .= drupal_attributes($element['#attributes']) .' />';
if (!is_null($element['#title'])) {
$checkbox = '<label class="option ' . $element['#options_class'] . '" for="'. $element['#id'] .'">'. $checkbox .' '. $element['#title'] .'</label>'; /************************* CUSTOM CODE BY PRASHANT SHAH *************************/
}
unset($element['#title']);
return theme('form_element', $element, $checkbox);
}
/**
* Format a set of checkboxes.
*
* @param $element
* An associative array containing the properties of the element.
* @return
* A themed HTML string representing the checkbox set.
*
* @ingroup themeable
*/
function theme_checkboxes($element) {
$class = 'form-checkboxes';
if (isset($element['#attributes']['class'])) {
$class .= ' '. $element['#attributes']['class'];
}
$element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
return theme('form_element', $element, $element['#children']);
}
else {
return $element['#children'];
}
}
function expand_checkboxes($element) {
$value = is_array($element['#value']) ? $element['#value'] : array();
$element['#tree'] = TRUE;
if (count($element['#options']) > 0) {
if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
$element['#default_value'] = array();
}
foreach ($element['#options'] as $key => $choice) {
if (!isset($element[$key])) {
$element[$key] = array(
'#type' => 'checkbox',
'#processed' => TRUE,
'#title' => $choice,
'#return_value' => $key,
'#default_value' => isset($value[$key]),
'#attributes' => $element['#attributes'],
'#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
'#options_class' => $element['#options_class'][$key], /************************* CUSTOM CODE BY PRASHANT SHAH *************************/
);
}
}
}
return $element;
}
|