Menu

#4 rule: checklist not working

open
nobody
None
5
2005-07-07
2005-07-07
No

There were errors in the lib/rules/checklist.php
preventing the display of the right values when editing
a record; here is my patched version:

<?php
// dataMiner - data browser / editor
// Jason Hines, jason@greenhell.com
// $Id: checklist.php,v 1.1 2004/08/17 23:41:08
openface Exp $

/**
* The CHECKLIST rule allows you to select multiple
values from a list
* of unique field values with checkboxes.
*
* required params:
*
* values (array) - array of options
*/
class checklist {

function checklist($field,$params,&$dm) {
$this->field = $field;
$this->values = $params;
$this->dm =& $dm;
}

function output_filter($data) {
$_arr = explode($this->dm->delimiter,$data);
$tmp = array();
foreach ($_arr as $key=>$value) {
$tmp[] = $this->values[$value];
}
return @join(", ",$tmp);
}

function input_filter($data) {
$_arr = @array_values($data);
return @join($this->dm->delimiter,$_arr);
}

function input_display($value) {
$i=0;
$_arr = explode($this->dm->delimiter,$value);
foreach ($this->values as $_value=>$_text) {
$i++;
$chk = in_array($_value,$_arr) ? "checked"
"";
print "\n<input id=\"{$this->field}_{$i}\"
type=\"checkbox\" name=\"{$this->field}[]\"
value=\"{$_value}\" {$chk}> ";
print "<label
for=\"{$this->field}_{$i}\">{$_text}</label>";
}
}

}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB