The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Create index number every time a user submits a form

Labels

This Discussion is public

Notifications

Hi

My goal is to create a form in which a user can enter a test score, for example 1.45 and a date, and then display the results in a line graph with dates on the x axis and the test score on the y axis.

I don't think that you can use dates as units on the x axis, is this correct?

If you cannot then I was hoping to create an alternative unit for x axis, such as a incrementing value.

For example, every time a users submits a form, the form would record a new incremental number with that submission.

Form submission by specific user 1 = incremental number 1

Form submission by specific user 2 = current incremental number 1 +1  = 2

Form submission by specific user 3 = current incremental number 2 +1  = 3

etc

If this works then I can plot the test score value against the incremental number.

However, the form would need to be aware of what current form submission number is for a user so that it can add 1 to it.

I think this can be done with a LookUp.

I am new to Formidable Forms so I would be grateful for any help on a direction to take to achieve the above.

Thanks

J

This is definitely achievable. I've done this to create parent/child relationships to related data elements. It requires that a user is logged in before he/she can create any forms at all, otherwise you won't have a way to tie the code to a specific form. If your process doesn't require login, then you need a unique ID to persist throughout the form relationships to tie them all together. Probably a combination of userid + unique id would work best to tie them all together.

The basic principle for getting this to work is this:

1. When form is saved, execute a SQL query to retrieve the maximum index number already stored for the batch of related forms
2. Increment the index number by 1
3. Assign the new number to a hidden field on the form
4. Save the form.

I would use the frm_pre_create_entry hook for this.

Discussion closed.