1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

BC Fix for userclass checkboxes.

This commit is contained in:
Cameron
2014-01-06 01:03:58 -08:00
parent f2ff881639
commit 0976668360
2 changed files with 21 additions and 4 deletions

View File

@@ -973,12 +973,23 @@ class e_form
* @param string $name
* @param mixed $value
* @param boolean $checked
* @param array $options
* @param mixed $options query-string or array or string for a label. eg. label=Hello&foo=bar or array('label'=>Hello') or 'Hello'
* @return void
*/
function checkbox($name, $value, $checked = false, $options = array())
{
if(!is_array($options)) parse_str($options, $options);
if(!is_array($options))
{
if(strpos($options,"=")!==false)
{
parse_str($options, $options);
}
else // Assume it's a label.
{
$options = array('label'=>$options);
}
}
$options = $this->format_options('checkbox', $name, $options);
$options['checked'] = $checked; //comes as separate argument just for convenience

View File

@@ -557,6 +557,7 @@ class user_class
public function uc_checkboxes($fieldname, $curval='', $optlist = '', $showdescription = FALSE, $asArray = FALSE)
{
$show_classes = $this->uc_required_class_list($optlist);
$frm = e107::getForm();
$curArray = explode(',', $curval); // Array of current values
$ret = array();
@@ -565,9 +566,14 @@ class user_class
{
if ($k != e_UC_BLANK)
{
$c = (in_array($k,$curArray)) ? " checked='checked'" : '';
// $c = (in_array($k,$curArray)) ? " checked='checked'" : '';
$c = (in_array($k,$curArray)) ? true : false;
if ($showdescription) $v .= ' ('.$this->uc_get_classdescription($k).')';
$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
$ret[] = $frm->checkbox($fieldname[$k],$k,$c,$v);
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
}
}
if ($asArray) return $ret;