Tracker plugin:
Imagine we would like to offer modification of a dynamic list field without offering modification of its reference field. In this case, the dynamic list should fall-back to a simple list with no selectValue calls in the js.
Proposal:
function prepare_dynamic_items_list($field, &$fields) { $refFieldId = $field['options_array'][2]; $refFieldOnTheForm = false; $fieldIdx = 0; foreach ($fields as $i=>$ff) { // get the item link field if ($ff['fieldId'] == $refFieldId) { $refFieldOnTheForm = true; $refFieldId = $i; } if ($ff['fieldId'] == $field['fieldId']) { $fieldIdx = $i; } } if (!$refFieldOnTheForm) { // we prentend it was an item list // the $fields[$fieldIdx]['list'] is to be filled in $fields[$fieldIdx]['type'] = 'r'; // caller may use a $fields[$fieldIdx]['list'] = array('kutya','macska'); } else { // ---- FROM HERE IT IS ALL OLD CODE if (!isset($fields[$refFieldId]['http_request'])) { $fields[$refFieldId]['http_request'] = array('', '', '', '', '', '', '', '', ''); } for ($i = 0; $i < 5; $i++) { if (!empty($fields[$refFieldId]['http_request'][$i])) { $fields[$refFieldId]['http_request'][$i] .= ','; } if (!empty($field['options_array'][$i])) { $fields[$refFieldId]['http_request'][$i] .= $field['options_array'][$i]; } } $fields[$refFieldId]['http_request'][5] .= ($fields[$refFieldId]['http_request'][5] ? ",":"") . $field['fieldId']; $fields[$refFieldId]['http_request'][6] .= ($fields[$refFieldId]['http_request'][6] ? "," : "") . $field['isMandatory']; $fields[$refFieldId]['http_request'][7] .= $fields[$refFieldId]['value']; $fields[$refFieldId]['http_request'][8] .= ($fields[$refFieldId]['http_request'][8] ? "," : "") . $field['value']; } }
Furthermore, add to wikiplugin_tracker.php, ~line 835, just after
foreach ($flds['data'] as $i=>$f) { // collect additional infos if (in_array($f['fieldId'], $outf)) { ... } elseif ($f['type'] == 'w') { RIGHT HERE -> }
the following
$trklib->prepare_dynamic_items_list($f, $flds['data']); if ($flds['data'][$i]['type'] == 'r') { // we prentended it was an item link $bindingItemLinkField = $trklib->get_tracker_field($f['options_array'][2]); $bindingValueIndex = $trklib->get_item_id($bindingItemLinkField['options_array'][0], $bindingItemLinkField['options_array'][3], $bindingValue); $flds['data'][$i]['list'] = $trklib->get_filtered_item_values($f['options_array'][1], $bindingValueIndex, $f['options_array'][3]); }
To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tiki.org instance. To start, simply select a version and click on "Create show2.tiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tiki.org.
filename | created | hits | comment | version | filetype | ||
---|---|---|---|---|---|---|---|
No attachments for this item |