Loading...
 
Skip to main content

Dynamic list does not work in the tracker plugin when its reference field (normally an item link) is not shown in the form, with patch

Status
Closed
Subject
Dynamic list does not work in the tracker plugin when its reference field (normally an item link) is not shown in the form, with patch
Version
5.x
Category
  • Consistency
  • Error
  • Usability
  • Feature request
  • Less than 30-minutes fix
  • Patch
Feature
Trackers
Resolution status
Fixed or Solved
Submitted by
Ushindi Gedeon
Lastmod by
Ushindi Gedeon
Rating
(0)
Description

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.

Solution

Proposal:

trackerlib.php
Copy to clipboard
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

Copy to clipboard
foreach ($flds['data'] as $i=>$f) { // collect additional infos if (in_array($f['fieldId'], $outf)) { ... } elseif ($f['type'] == 'w') { RIGHT HERE -> }


the following

Copy to clipboard
$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]); }
Workaround
Importance
8
Easy to solve?
8
Priority
64
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
3113
Created
Tuesday 13 April, 2010 23:12:59 UTC
by Gergely
LastModif
Tuesday 02 June, 2026 08:26:15 UTC


Show PHP error messages