View Issue Details

IDProjectCategoryView StatusLast Update
0011420phpList 3 applicationDocumentationpublic13-02-19 12:27
ReporterLuke The Obscure 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Product Version2.11.3 
Target VersionFixed in Version 
Summary0011420: Contribution - columns for checkboxes
DescriptionThis hack will allow you to create multiple columns for check-boxes. Very handy for larger lists of items!
Additional InformationI did not write this code, but I found it so useful that I was suprised it's not in the main release. Found in the forumns (line numbers are different in current version):

subscribelib2.php:
Change 'case "checkboxgroup"' Line 817 to the code below:
Code:
//-----------------------------------------------------------//
case "checkboxgroup":
$output[$attr["id"]] .= sprintf("\n".'<tr><td colspan=2><div class="%s">%s</div></td></tr>',$attr["required"] ? 'required' : 'attributename',stripslashes($attr["name"]));
$output[$attr["id"]] .='<tr><td colspan=2><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr>'; // creates table within table
$values_request = Sql_Query("select * from $table_prefix"."listattr_".$attr["tablename"]." order by listorder,name");
$col = getConfig("checkboxgroupcolumns"); // gets config data
$colcount = 1;
while ($value = Sql_Fetch_array($values_request)) {
  if (isset($_POST[$fieldname]))
    $selected = in_array($value["id"],$_POST[$fieldname]) ? "checked" : "";
    else if (isset($data[$attr["id"]])) {
      $selection = explode(",",$data[$attr["id"]]);
      $selected = in_array($value["id"],$selection) ? "checked":"";
    }
    if($col>1 && $colcount<$col) {
      $colcount++;
      $output[$attr["id"]] .= sprintf("\n\t".'<td class="attributeinput"><input type=checkbox name="%s[]" class="attributeinput" value="%s" %s> %s</td>',$fieldname,$value["id"],$selected,stripslashes($value["name"]));
     } elseif($colcount>=$col) { //inserts new column
       $output[$attr["id"]] .= sprintf("\n\t".'<td class="attributeinput"><input type=checkbox name="%s[]" class="attributeinput" value="%s" %s> %s</td></tr>'."\n".'<tr>',$fieldname,$value["id"],$selected,stripslashes($value["name"]));
       $colcount=1;
     }
   }
   $output[$attr["id"]] .= '</tr></table></td></tr>'; //ends table
break;
//-----------------------------------------------------------//



AND

in defaultconfig.inc Line 170 Insert the code:
Code:
//-----------------------------------------------------------//
# how many columns checkbox groups will have
"checkboxgroupcolumns" => array("2","How many columns would you like to use for CheckBox Groups (numerical)","text"),
//-----------------------------------------------------------//
TagsNo tags attached.

Activities

There are no notes attached to this issue.