Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
#1092 TV @file binding not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yama committed Dec 12, 2016
1 parent 80003c8 commit 37fe7bb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions manager/includes/tmplvars.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,21 @@ function renderFormElement($field_type, $field_id, $default_text = '', $field_el
$field_html .= '</select></td><td>';
$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>';
break;
case "checkbox": // handles check boxes
$field_value = !is_array($field_value) ? explode("||", $field_value) : $field_value;
case 'checkbox': // handles check boxes
$values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
static $i = 0;
while (list($item, $itemvalue) = each($index_list)) {
list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
if (strlen($itemvalue) == 0) $itemvalue = $item;
$field_html .= '<input type="checkbox" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'[]" '.(in_array($itemvalue, $field_value) ? " checked='checked'" : "").' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="checkbox">'.$item.'</label><br />';
$tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />';
$i = 0;
$_ = array();
foreach ($index_list as $c=>$item) {
$item = trim($item);
list($name, $value) = (strpos($item,'==')!==false) ? explode('==', $item, 2) : array($item, $item);
$checked = in_array($value, $values) ? ' checked="checked"' : '';
$param = array($modx->htmlspecialchars($value), $i, $field_id, $checked, $modx->htmlspecialchars($name));
$_[] = vsprintf($tpl, $param);
$i++;
}
$field_html = join("\n", $_);
break;
case "option": // handles radio buttons
$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
Expand Down

0 comments on commit 37fe7bb

Please sign in to comment.