1

I was wondering if anyone can help me. I've got an events channel with a 'number of places available' number field, which users uploading an event populate with how many spaces they have available for an event. When people book an event, through freeform, I want them to input a number as to how many places they want, and for this number to be substracted from the 'number of places available' number field. Does anyone know of a module or fieldtype that could do this?

Thanks, Julie

1

Take a look at my answer here.

There I recommend using Safecracker instead of Freeform, to store these as entries. You can then use an add-on or your own PHP code to handle the email notifications that Freeform would have generated.

When using Safecracker, you'll want to have a postprocessor template as your redirect URL. In that template, you can use exp:query to update your database, or PHP. Either way, you'll be manipulating those values directly.

You can include the new entry's ID on the redirect URL for reference in your postprocessor template. You can set PHP to output, and get the entry using exp:channel:entries entry_id="{segment_x}".

Within that postprocessor template, you can have a redirect to send the user on to the target destination.

Updated: I'm suggesting Safecracker as it will ultimately give you more flexibility in your event management data. If you think of it as a relational database, you have event records and registration records. Those are really registration entries in a registration channel, referencing an event. You'll ultimately have more flexibility in this sort of system by treating those as a channel, and possibly find exp_channel_data easier to manipulate.

Freeform also has a post submit hook. You can write an extension that will manipulate your Event channel data using PHP/SQL in an extension, and register that extension to run every time a particular form is submitted. But I'd consider storing relational data entirely in channels, not split between a channel and Freeform. That way you can do custom reports with exp:channel:entries, etc.

5
  • Thanks for your reply Mark. I understand the bit about using a postprocessor template but could I not have a postprocessor template as a redirect/return url using freeform? Why would I need to use safecracker?
    – Julie
    Feb 11 '13 at 16:46
  • Hi Julie – Updated original answer with additional thoughts. Feb 11 '13 at 16:52
  • Ok thanks. How would I pass data, like event entry id, to the postprocessor template so the database updates the field for the correct event?
    – Julie
    Feb 11 '13 at 17:08
  • Updated with a link to that in the Safecracker docs. Feb 11 '13 at 17:27
  • Great thanks Mark, I'll give this a go tomorrow.
    – Julie
    Feb 11 '13 at 17:39
0

Mark Reeves is correct in stating that this could potentially be better handled within the Channel Entries, just using SafeCracker Form to complete. Not because Free Form Pro couldn't handle the job and well. But primarily, because most add-ons work on channel entries. Though if it is a plugin that's applied via the template, then it should work on Free Form Pro as well.

Basically your looking for plugins for two things:

Derek Hogue, Amphibian Design, has created Tally which is a plugin that would allow you to easily retrieve total 'tickets' or 'registrations' for the event, then either PHP or a second 'math' based plugin could be used to do the subtraction. I've used 'Math' by and have heard good things about MX Calculator, but have never used it. Normally, if necessary, I just drop into PHP.

You'll want to — Total the number of RSVPs, subtract RSVPs/attendees from max registration field. Display remainder. (which you've mentioned), but you'll also need to stop the registration process, when max attendees has been reached. This can be done via CSS, hiding the submit button from view, and maybe a modification to the submit id, so if people are using screen readers or use to pushing 'enter', that the submit fails.

It's doable, either way, Free Form or SafeCracker. The plugins should/may work on the Free Form fields, so give them a try. But they aren't really submitting data back to the system, just doing math on the template itself. Which is why you need to put safeguards in place to stop registrations over the max total.

1
  • Thank you very much for your answer. The plugins look good, i'd probably use Tally and then php for the calcualtion. I'll give Marks answer a go and then try this if it fails.
    – Julie
    Feb 11 '13 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.