function checkboxes($path, $items, $itemValue = null, $itemLabel = null, $options = array()) { global $request; if (!is_array($items)) { show_error('$items must be an array'); } $name = _get_complete_bind_path($path); $bindStatus =& new BindStatus(_get_bind_path($path)); $contents = ''; foreach ($items as $key => $value) { if (is_object($value)) { if (!is_null($itemValue) || !is_null($itemLabel)) { $bw = new BeanWrapper($value); } $iVal = is_null($itemValue) ? $value : $bw->getPropertyValue($itemValue); $iLabel = is_null($itemLabel) ? $value : $bw->getPropertyValue($itemLabel); } else { if (is_string($key)) { $iVal = $key; $iLabel = $value; } else { $iVal = $value; $iLabel = $value; } } $iVal = _get_display_string($iVal, $bindStatus->getEditor()); $iLabel = _get_display_string($iLabel, $bindStatus->getEditor()); $id = $name . '_' . $iVal; $checkbox = checkbox_tag($name . '[]', $iVal, SelectedValueComparator::isSelected($bindStatus, $iVal) || SelectedValueComparator::isSelectedUsingBeanWrapper($bindStatus, $iVal, $itemValue), array_merge(array('id' => $id), $options)); $contents .= content_tag('label', $checkbox . ' ' . $iLabel, array('for' => $id)); } $contents .= input_hidden_tag('_' . $name, '1'); return $contents; }