The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Show ID in form table view not working as expected - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Show ID in form table view not working as expected (/showthread.php?tid=1134)



Show ID in form table view not working as expected - commbot - 09-04-2018

Hi,

I've been trying to show ID in a new form table view but it doesn't seem to be working. The header ID is shown, but the content is missing. The reason being I wanted to create a link in order to update a table entry and couldn't find a way to get the row ID. Maybe there's a set of functions I missed?

Anyway, the bug seems to be where the table is reordered before being displayed, in that the ID value is held in the form itself, but the ID field is not part of the form_form, so doesn't get merged.

Fixed this by adding the ID field to the order array like so:


Code:
foreach($t as $r){
    
    if($opts['id'] == 1){ $order = array('id'=>'ID') + $order; }. // added this line to fix, code continues below
             
    // All of this is to get the table in the same order as your form
    $r = array_intersect_key($r,$order);                 
    $r = array_merge($order,$r);


I'm trying to display a form with an edit link so the entries can be updated, couldn't find an easier way to do it Smile