Created
June 21, 2011 18:46
-
-
Save erkattak/1038562 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkbox_list ($data, $name = 'list', $parent = 0, &$label = null) { | |
if (!empty($data)) { | |
echo '<div class="categories sub">'; | |
foreach ($data as $item) { | |
if (isset($item['children']) && !empty($item['children'])){ | |
$label .= (isset($label)) ? ' ' . $item['name'].' »' : $item['name'].' »'; | |
checkbox_list($item['children'], $name, $item['id'],$label); | |
}else{ | |
echo (isset($label)) ? '<h3>'.$label.'</h3>' : false; | |
echo '<label for="'.$name.'_'.$item['id'].'"><input type="checkbox" name="'.$name.'[]" value="'.$item['id'].'" id="'.$name.'_'.$item['id'].'" />'.$item['name'].'</label>'; | |
unset($label); | |
} | |
} | |
echo '</div>'; | |
} | |
} | |
checkbox_list($classifications); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment