Create a Registration Form with Limited Availability

Scenario

You want to prevent users from submitting a form if certain criteria are reached. For example, you’re hosting events with limited seating.

Once the seating limit for the event is reached, you want to make sure no more users can register and alert them that the event is full. In Knack, this kind of scenario can be accomplished using page rules.

 

Forms can also be prevented from being submitted by using validation rules on fields to limit what kind of data users can enter in forms.

 

At the end of this article, you will have a working page for users to register for limited-availability events. If the event is no longer available, the user will see an alert message, and the registration form will be hidden.

Requirements

This article assumes you already have the following requirements fulfilled:

  1. A parent table (Events) that needs a limited amount of connected records

  2. A child table (Registrations) with a one-to-many connection to the parent (Events)

  3. A start page displaying records from the parent table (Events)

If this is your first time creating an app, you'll need to know some basics about adding tables, fields, pages, and views. You can start by reading our Builder Basics section. 
Other good resources can be found in our About Your Database and Working With Pages article in our knowledge base.

Steps

Add a Field to Track the Limit

You’ll need to store the number of children (Registrations) that each parent record (Event) is limited to. In the Events table, add a new number field called "Registration Limit":

 

Add a Field to Count Registrations

Before you can prevent the user from doing anything, you need to know how many registrations have already been submitted for a specific event.

In the Events table, add a count field called "Registration count" that counts the number of Registration records:

 
 

Don’t see a "Count" field as an option? Make sure that your Registrations table has a connection pointing to the Events table.

 

You can read more about using formula fields here.

Add a Field to Calculate the Remaining Registrations

Now that you have a field storing the registration limit and the registration count, you can calculate the remaining registrations by subtracting the count field in step 2 from the limit field in step 1.

In the Events table, add a new equation field called "Registrations Remaining" with the following formula:

{Registration Limit} - {Registration Count}

 

 

You can read more about using equation fields here.

Your Events table should now look like this:

 

Add a Child Page

Find the start page that users will access to view the Events. If you don’t have one yet, you can follow the steps here to create a new page.

If you already have an existing start page with views, you can click on the "Actions" tab while adding fields in your view editor to add a new link to view more details. You can read more on action links here.

Regardless of which step you take when creating your new child page, be sure to add a form to create a new registration form connected to the Event on that page.

 
 

Not seeing the form option for "Registrations"? Make sure you have a connection between the Event and the Registration.

Add the Page Rules

The final step is to add page rules that will trigger when the number of registrations reaches the limit. From the child page, click on the "Rules" tab in the top menu and click on the “Add Rule” button to add your first rule.

For the first rule, set your rule criteria so that it triggers when "Remaining Registrations" is lower than 1. The first rule will hide the registration view, so the action should remain as "Hide views". Click the box for the “Add Registration form”:

Add a second rule with the same criteria as the first rule and set the "action" to “Show a message.” Finally, configure your message by choosing between four different backgrounds, writing your own message, and choosing whether the user can or can not dismiss the message.

Save the rules by pressing the Save Changes button.

 

 

You’re now successfully hiding the registration view as soon as the registration limit reaches 0!

 

Notes

  • This will not prevent a single user from submitting multiple registrations. The count is based on all connected child records.

  • You can add filters to your count and only track "paid" registrations, exclude "canceled" registrations, etc.