RSVPList
Creating an RSVP List - PmForm Example
I run many websites with event pages, and it would be nice to have a cute little RSVP form that will create a list of people who have RSVP'd to an event. Can I do that with PmWiki?
While I would prefer to have a list under each of "yes" "no" and "maybe" PmForm doesn't have that ability yet, so I made a list that could easily be sorted & search-replaced if needed to get a list of RSVPs for event attendance while still looking nice to the webpage visitor. Hopefully this will help if you need to create a PmForm to process data or comments onto the same page as the form.
Summary
- Install PmForm (see PmForm Installation instructions)
- Define the PmForm reference
- Add PmForm template to Site/LocalTemplates
- Add PmForm directive to desired page(s)
- Save & Test
Define the PmForm reference
Add a line like the one below to your config.php
file, after the include line for PmForm:
$PmForm['rsvp'] = 'saveto={$FullName} form=#rsvpform fmt=#rsvppost';
This is a very simple reference: it adds the definition for the "rsvp" PmForm directive to the $PmForm array (i.e. the index in the array will be used in the PmForm directive below). The "saveto" will tell it to save the form data to the current PmWiki page (defined by variable {$FullName}
). "form" and "fmt" refer to the PmForm templates created in the next step.
Add PmForm template to Site/LocalTemplates
These templates are explained line-by-line below.
[[#rsvpform]] (:input pmform target=rsvp :) (:input default request=1:) (:input default author "{$Author}" :) Please RSVP for the event: (:messages:) %comment% $[Subject]: (:input text Subject size=30:) Name: (:input text author:) ||width=50% ||(:input radio anchor "I'll be there.":) Yes ||(:input radio anchor "I can't make it.":) No ||(:input radio anchor "I might be there.":) Maybe || (:input submit post "Submit":) (:input end:) [[#rsvpformend]] [[#rsvppost]] (:template defaults where=below :) (:template require author errmsg="$[Missing name]":) (:template require author match="-*:*,-*@*,-*<*,-*>*" errmsg="Please just enter your name.":) (:template require Subject match="" errmsg="$[Please leave the subject field blank]" :) *"{$$anchor}" ~{$$author} [[#rsvppostend]]
Add PmForm directive to desired page(s)
You must use the (:pmform:)
directive with the index used in the $PmForm array.
(:pmform rsvp:)
Save & test
Line-by-Line explanation of the form template
Start the form template definition
[[#rsvpform]]
The name for this anchor is defined in the $PmForm
array definition in your config.php file.
Define the form type and the PmForm index
(:input pmform target=rsvp :)
Uses the same $PmForm
array index used in your config.php file.
Give the form an OK to use previously submitted data
(:input default request=1:)
If the user makes an error and needs to resubmit, the form will refill with previously submitted information.
Use the current Author's name
(:input default author "{$Author}" :)
Elegant in case they're logged in or have already edited a page on the site and filled in the Author field, or if they've already RSVP'd for an event on another page.
Start the visible portion of the form
Please RSVP for the event:
Make form messages visible
(:messages:)
Will be replaced with form processing directives, defined below or produced by the PmWiki internal form processing or PmForm system. You may want to wrap this line with styling to make the error messages more visible:
>>red<< (:messages:) >><<
You can also style form messages using CSS.
Add a honeypot form field
%comment% $[Subject]: (:input text Subject size=30:)
This is a diversionary tactic to detect spam. The theory is that automated spam applications (spambots) would presume this is an email form and fill this form in with some type of text. It is hidden with CSS (
Continue with normal form fields
Name: (:input text author:) ||width=50% ||(:input radio anchor "I'll be there.":) Yes ||(:input radio anchor "I can't make it.":) No ||(:input radio anchor "I might be there.":) Maybe || (:input submit post "Submit":)
End the PmForm template definition
(:input end:) [[#rsvpformend]]
The first line ends the