The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
How to append counter in submission list instead of id - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: How to append counter in submission list instead of id (/showthread.php?tid=1246) |
How to append counter in submission list instead of id - ferri - Apr 28th, 2011 Hi, In the View Submissions, I would like to have an incremental counter in the table list (with heading: No.) instead of id number. How do I implement this so that if a submission is deleted, the number will be updated automatically. Thanks! RE: How to append counter in submission list instead of id - crunchers - Apr 29th, 2011 There's no way to do it from within the control panel but I guess you could manually change the field name of the particular form from "ID" to "No." (access to phpMyAdmin or some similar program will help you accomplish this). Why not just leave it as ID? Also, if you're asking how to automatically update all submissions ID values whenever a form is deleted (presumably so they all increment by 1, starting from 1) , you'd need to make a composite of the primary key of the table under a new field whenever the table (of form) is created. It probably wouldn't work reliably since you'd need to account for any forms that aren't finalised; you're liable to run into concurrency issues if you were to do it this way. The way I'd approach it is to create a new field called "No.", and then write a function to trigger whenever a submission is created/deleted that retrieves the number of entries that exist within that table where the corresponding "is_finalized" field equals "yes"; then re-index the "No." field accordingly. It would require a core hack to FT (a PITA to manage when dealing with updates) but I believe there is a hooks module that may allow you to do this without needing you to mess around with the source files. I'm still learning PHP/mySql but that's certainly how I'd approach it. RE: How to append counter in submission list instead of id - Ben - Apr 30th, 2011 Hey Ferri, Crunchers - you're totally right, you'd need the Hooks Manager module, and do the logic you suggested. I just wrote up the following tutorial on how to do it: http://docs.formtools.org/tutorials/auto_increment/ Let me know if I'm not clear on any of it, or if it's not quite what you had in mind! - Ben |