Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Fjord 659 posts 1546 karma points c-trib
    Jun 08, 2015 @ 09:53
    Rasmus Fjord
    0

    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.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jun 08, 2015 @ 10:26
    Tim Geyssens
    0

    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...

  • Rasmus Fjord 659 posts 1546 karma points c-trib
    Jun 08, 2015 @ 10:27
    Rasmus Fjord
    0

    That would be awesome Tim

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jun 08, 2015 @ 10:41
    Tim Geyssens
    1

    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

  • Rasmus Fjord 659 posts 1546 karma points c-trib
    Jun 08, 2015 @ 11:07
    Rasmus Fjord
    100

    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 ? 

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jun 08, 2015 @ 12:57
    Tim Geyssens
    0

    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

  • Rasmus Fjord 659 posts 1546 karma points c-trib
    Jun 08, 2015 @ 14:40
    Rasmus Fjord
    0

    Nah i wont take that approach either, ill make it node based and hook into the event.

  • Rasmus Fjord 659 posts 1546 karma points c-trib
    Jun 15, 2015 @ 07:06
    Rasmus Fjord
    0

    Thx for the help tim, couldnt mark your answer as the answer for some reason :( So marked my own so it got "answered".

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jun 15, 2015 @ 07:46
    Tim Geyssens
    0

    No problem, glad I could help :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies