Jump to content

Create quick and simple event RSVP form?


modifiedcontent
 Share

Recommended Posts

Thanks for the response Adrian. I was trying to follow that thread, all nine pages, and completely lost the plot. That's why I posted my question.

If I want a form of one field, to add a name to a guest list/database, what would that look like in PW?

Do I need a module or can I use core features?

Should I create a Page with Children first as a database where the data from the field can be stored?

Is there an example or explanation anywhere that is more step-by-step?

Soma's thread - from 2012, five years old! - start presupposing that you know lots of stuff already. I don't know formbuilder etc. - I see it is a $180 pro module, is forms really that complicated in PW? Soma's thread is more like a theoretical discussion between coders.

This thread has some starting points:

I guess this module could be modified to serve as an RSVP form:

http://modules.processwire.com/modules/newsletter-subscription/

Someone also had a probably usable code suggestion for this in 2012, with feedback from Ryan:

 

Link to comment
Share on other sites

To be honest, although that thread shows you how you can use the PW API to create (read, the HTML) forms, 'a basic (or non-basic) PW form' does not exist; You need to create a HTML form and use ProcessWire to process that form. It is that simple. OK, back to crux of the matter; how to handle user registration from the frontend. 

There are several issues/steps here:

  1. How to create the form (simple; use a HTML form)
  2. Where to post that form (i.e., post to the page where the form is displayed, or post to another page)
  3. How to handle spam + cross-site forgery
  4. How to handle double registrations
  5. Feedback to the user once form has been submitted
  6. How to deal with errors/validation - client and server-side
  7. How to process the form inputs on the server-side (including sanitizing inputs)
  8. How and where to save form inputs
  9. How to send confirmation email

Tackling above:

  1. Create Form: This is simple. Create your HTML form in a template file. I suggest using 'post' for method and action to post to self, i.e. './'
  2. Post destination: I've suggested posting to self, but you can use some other URL (i.e. an existing page).
  3. Spam: I suggest using a honeypot or double honeypot AND CSRF (see $session->csrf). Please Google this forums for examples. If I get time to do this I'll update this post.
  4. Double registrations: You would need to check submitted email against saved emails. 
  5. User Feedback: Some people prefer to redirect to a different page with a thank you message, others reload the same page but don't show the form, just the thank you message. Up to you. If redirecting, see $session->redirect()
  6. Errors + Validation: I suppose you know how to deal with client-side validation. Server-side, you will use $input->post; Use that to check if all required inputs sent; Use $sanitizer to sanitize inputs, e.g. $sanitize->email() for emails. 
  7. Process Form: See #6.
  8. Save Guest: This depends on how you want to save guests. Do you have an external database? Then make use of $database.  However, I would go for pages, whereby, each registration is a page, tucked away under some parent page. The title of the page could be the guest's full name and the email would be saved in an email field. This means a template with two fields; title and email.
  9. Confirmation Email: See WireMail

Sorry, it's getting late here and cannot give you specific examples. Hopefully the above will give you some food for thought. Happy to provide more details later if you get stuck. Others may chime in too, so, you should be alright :-).

ps: If you will be dealing with forms a lot, I recommend investing in Form Builder.

Edited by kongondo
  • Like 3
Link to comment
Share on other sites

1 hour ago, kongondo said:

ps: If you will be dealing with forms a lot, I recommend investing in Form Builder.

Purchasing a dev licence for Form Builder is a no-brainer: if you place a dollar value on your time you will quickly realise that after only a small number of forms it has saved you $$$. ;)

  • Like 2
Link to comment
Share on other sites

7 hours ago, modifiedcontent said:

Soma's thread - from 2012, five years old! - start presupposing that you know lots of stuff already. I don't know formbuilder etc. The thread is like a theoretical discussion between coders.

Maybe you can show us what you've tried? I just copied/pasted Soma's example and the core of it stills offers a starting point for using PW core inputfields in custom forms.

Here's how the result looks:

somaform.PNG

This is with the code Soma gives for the form and the head.inc which he gives in the mentioned thread. You'll have to make it functional for your needs but it gives you a starting point.

  • Like 2
Link to comment
Share on other sites

Thank you for all your responses. kongondo's response in particular was really helpful in focusing my attention.

szabesz, I have been working on a front-end user registration system as well, have been following that thread:

I am now trying to wrap my head around the basics of forms in PW; a generic form, just getting some data submitted to a database.

Isn't Soma's thread/example mostly about rendering the form through the API, input fields etc., not so much about how the data gets processed?

If it is possible to just use a plain html form in a template, I'd like to start there. The main thing I need to understand today is how to process the data from the form, how to get it into the database via PW. I'll follow up when I have tried some things...

Ryan gave a very clear explanation of how to work with the database in Processwire:

BTW, apologies for my dumb questions. I also use these threads to keep track of my own "research" and hopefully that will help others in the same situation.

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...