I have similar problem. I want to change the multipleselect extra field list of K2 Add new article, with check boxes. I did something but not perfect, similar to radiolist:
in file administrator/components/com_k2/models/extrafield.php
Code: Select all
case 'multipleSelect':
$output=JHTML::_('select.genericlist', $defaultValues, 'K2ExtraField_'.$extraField->id.'[]', 'multiple="multiple"', 'value', 'name',$active);
break;
change with:
Code: Select all
case 'multipleSelect':
$output=JHTML::_('select.checkboxlist', $defaultValues, 'K2ExtraField_'.$extraField->id.'[]', '', 'value', 'name',$active);
break;
in file libraries/joomla/html/html/select.php
add:
Code: Select all
/*custom checkbox*/
function checkboxlist( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $idtag = false, $translate = false )
{
reset( $arr );
$html = '';
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id_text = $name;
if ( $idtag ) {
$id_text = $idtag;
}
for ($i=0, $n=count( $arr ); $i < $n; $i++ )
{
$k = $arr[$i]->$key;
$t = $translate ? JText::_( $arr[$i]->$text ) : $arr[$i]->$text;
$id = ( isset($arr[$i]->id) ? @$arr[$i]->id : null);
$extra = '';
$extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
if (is_array( $selected ))
{
foreach ($selected as $val)
{
$k2 = is_object( $val ) ? $val->$key : $val;
if ($k == $k2)
{
$extra .= " selected=\"selected\"";
break;
}
}
} else {
$extra .= ((string)$k == (string)$selected ? " checked=\"checked\"" : '');
}
$html .= "\n\t<input type=\"checkbox\" name=\"$name\" id=\"$id_text$k\" value=\"".$k."\"$extra $attribs />";
$html .= "\n\t<label for=\"$id_text$k\">$t</label><br>";
}
$html .= "\n";
return $html;
}
/*end custom checkbox*/
I save the article and everything is normal.
The only problem is when I edit the artcile, I have to check every option again.
If someone can help me to solve this problem I'll be thankfull.