The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append counter in submission list instead of id
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.

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.

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:

Let me know if I'm not clear on any of it, or if it's not quite what you had in mind! Smile

- Ben

Forum Jump:

Users browsing this thread: 2 Guest(s)