When using Participants Database to represent two or more classes of people or things, you sometimes need to customize the frontend edit form so that is only shows the fields that are relevant to the type of record that is getting edited. We can easily do this with a custom template.
If you’re not familiar with the use of custom templates, read this article: Using Participants Database Custom Templates
For our example, we are continuing the example used in āMultiple Databasesā with Participants Database where you have a kid’s sports team and you have records for the players and the parents. We want to show a different record edit form for each of the two classes of people.
When someone wants to edit their record, they will typically use either a “private link” or a login page provided by the Particpant Login add-on. The way this works, when they go to their edit record page, we use a custom template to determine what kind of record edit form to show, and then the template invokes the record edit form with the desired parameters. It’s a template that uses shortcodes, as you will see.
As in the example, you have your fields organized into three groups: “contact”, “player” and “parent”. The “contact” group is used for all records and the other two are specific to the type of person. There is a field named “type” that tells us which type the record is for, and we use that to determine which set of field groups to show.
Here is a custom template that does that, it is named pdb-record-usertype.php
To use the template, use this shortcode on your record edit page:
[pdb_record template=usertype]
That’s it! Of course, you’ll need to customize this to your particular situation, but that is the general technique.
Hi Roland, Is it possible to edit a record by multiple users (judges) simultaneously?
Use case:
We are running a Yoga/Sports competitions. Where Judges need to enter scores for a particular player simultaneously from different user sessions (their own mobiles/ Tabs).
On Record 1: we have separate fields for both judges > score1, score2.
Judge1 > enters the Score1 > submit (at timestamp1)
Judge2 > enters the Score2 > submit (at timestamp2)
Now, will the record get updated with both scores? or the latest timestamped set?
My doubt is that as they hold a separate session, it may hold entire original record values and the new field value will be pushed to database as latest update.
My requirement is to have all judges entries to be updated to the same record without affecting each others, regardless of the timestamps. How do i achieve this?
Thank you
The only way to safely do this is to use a Participant Log and let each judge add a log entry to the record with their score. You can set up the log to tally the scores and provide the result.
If you have them edit the record directly, you will run into problems.
Thanks Roland!.
Meanwhile, I tried to do it this way.
For judge1> page1> created a [pdb_record fields="score1"]
For judge1> page2> created a [pdb_record fields="score2"]
It is able to fetch and update only that field value to database, without affecting any other fields. Tested with updating the record with both scores using different login sessions simultaneously. I am able to achieve this successful. But…
But, I created another Calculation field from those scores, which is not getting updated dynamically. I have to open the full record and just click the submit button again to take the calculation effective. This is not possible to do it like that for every player during competitions. I read your documentation related to calculations and seems it wont get updated dynamically (I don’t find a comment section under that topic to put this question there. so asking that question also here. sorry.) How to achieve live update calculation field. I want to create a Leaderboard page where I want to put the TOP 3 players live final scores (I will refresh the page manually) and display on Screen/Monitor/TV.
What you’re trying there may not work. The calculated field is updated when the record is edited, so every time a judge submits a score, the value of the calculated field will be updated. The only way to have some kind of live update in the leaderboard is for the display to be updated by reloading the page. Unless you have to skills to update it in realtime, which is technically possible, but you’d have to build that yourself.
Based on our requirements, I am thinking of removing the calculation field all together from the record. Instead, I will just let the judges (as many) feed their scores. So that record will hold all the scores in it. After competitions are over for all players, we will export the data and do the required formula calculation in excel. That will be quicker and accurate in our case i think. Then we will announce the results.
Thank you Roland!