Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Formie Quota

Private Craft CMS 5 plugin adding a "Radio Buttons (Kontingent)" field type to Formie: a Radio Buttons field where every option has a limited quota.

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+
  • Formie 3.0+

How it works

  • Each option gets a "Kontingent" number, entered in the field's options table in the form builder (alongside label, value, default, disabled).
  • The remaining amount is never stored - it's computed live by counting completed, non-spam, non-deleted submissions that selected that option. Deleting a submission (or marking it as spam) frees its slot again automatically, with nothing extra to keep in sync.
  • A submission is rejected on save if its selected option's quota is already used up.
  • On the front-end, the remaining quota is shown in parentheses next to each option's label, and an exhausted option's input is rendered disabled.
  • Quota tracking is scoped per field instance (Formie's field UID), so using this field type on multiple forms tracks each one's quota independently - no shared quota pool across forms.

Known limitation

Counting submissions instead of maintaining a dedicated, atomically updated counter means there is a small race window: two submissions arriving in the same instant for the very last slot could in theory both get through. This trade-off was made deliberately in favour of not maintaining a separate database table. If that ever becomes a real problem, the fix would be a SELECT ... FOR UPDATE lock on the field's own row in formie_fields during the check, not a new table.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages