How to create a form limiting the number of registration

I want to create a registration form for training, but I also want to limit the number of entries for the simple reason that my training room has a limited number of places. How to do this?

« Back to Table of Contents

First step :

Add a "Whole number field", for example 'nb_inscriptions' with :

  • Minimum Acceptable Value = 1
  • Maximum Acceptable Value = 8
  • Field Help = "number of free places = 8"

Second step :

Add a script action name "decrement_place" and add in form action of your form. below the code for the script :

request = container.REQUEST
form = request.form

maxval = container.nb_inscriptions.fgField.maxval
nb_inscriptions = form.get('nb_inscriptions',None)

maxval = int(maxval) - int(nb_inscriptions)

if maxval < 0 : maxval = 0

message = 'number of free places : %d' % (maxval)

container.nb_inscriptions.setMaxval(maxval)
container.nb_inscriptions.setDescription(message)

 

Contact : Fabrice Monaco (fmonaco@cirb.irisnet.be), CIRB