Posts: 6
Threads: 5
Joined: Apr 2011
Reputation:
0
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!
Posts: 46
Threads: 17
Joined: May 2010
Reputation:
0
Apr 29th, 2011, 7:02 AM
(This post was last modified: Apr 29th, 2011, 8:57 AM by crunchers.)
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.