Creating a "seats" property that counts down from every added post
Hey there
i want to create a custom contour property that counts down from a value set on the form it self, so that only 10 could sign up for a form. Like reservations. Ive read the examples i could find but im missing a key ingridient.
Is there a way to update the "defaultValue" on a form when an entry is saved ? so that i could use it as a "countdown". Is there an event or something like it I could hook into.
Hey Rasmus, I can share an example of how we handle it on the cg site if that would be helpful.. it's slightly different from the way you describe it is a working solution...
In Umbraco we have event content pages where the doctype for those pages has a property maxAttendees, on the template we added the form...
When submitting the form it will create new attendee subnodes of the event page (you can just use the default save as umbraco document workflow for that)
But of course we need to prevent the form from submitting when the max attendees count has been met
Basicly that check happens when validating the form (for that you'll need to subscribe to the correct event)
The example is for Forms, if you are using Contour look for the Umbraco.Forms.Mvc.Controllers.FormRenderController.FormValidate event (rest of the code should be similar)
On your template it's now also easy to hide the form when the max count is met
That's the quick intro, you need more details just let me know
It is possible, but wouldn't be the recommended approach, since several people can load the form in the initial state and then change it simultaneously
Creating a "seats" property that counts down from every added post
Hey there
i want to create a custom contour property that counts down from a value set on the form it self, so that only 10 could sign up for a form. Like reservations. Ive read the examples i could find but im missing a key ingridient.
Is there a way to update the "defaultValue" on a form when an entry is saved ? so that i could use it as a "countdown". Is there an event or something like it I could hook into.
Comment author was deleted
Hey Rasmus, I can share an example of how we handle it on the cg site if that would be helpful.. it's slightly different from the way you describe it is a working solution...
That would be awesome Tim
Comment author was deleted
In Umbraco we have event content pages where the doctype for those pages has a property maxAttendees, on the template we added the form...
When submitting the form it will create new attendee subnodes of the event page (you can just use the default save as umbraco document workflow for that)
But of course we need to prevent the form from submitting when the max attendees count has been met
Basicly that check happens when validating the form (for that you'll need to subscribe to the correct event)
https://gist.github.com/TimGeyssens/f6a0a5118eca63296d40
The example is for Forms, if you are using Contour look for the Umbraco.Forms.Mvc.Controllers.FormRenderController.FormValidate event (rest of the code should be similar)
On your template it's now also easy to hide the form when the max count is met
That's the quick intro, you need more details just let me know
Arh yea that is an easier and prettier solution and makes complete sense.
Just out of pure curiosity is it possible through the API to change the the "form" it self, and its fields, just like my original thought was ?
Comment author was deleted
It is possible, but wouldn't be the recommended approach, since several people can load the form in the initial state and then change it simultaneously
Nah i wont take that approach either, ill make it node based and hook into the event.
Thx for the help tim, couldnt mark your answer as the answer for some reason :( So marked my own so it got "answered".
Comment author was deleted
No problem, glad I could help :)
is working on a reply...