Jump to content

Getting the basics right


3Dots
 Share

Recommended Posts

Hey guys

I'm currently learning PW and I need to wrap my head around a few concepts I guess.  At first I was wondering why there were no real form and db API methods.  After all, how can you allow a user to fill in a form and save the resulting data in the db?

A post from Joss gave me some valuable insight into what a page is.  So I'm guessing that a "record" in the db is actually a page.  And the way to process a form filled in by the user is to build my own form, catch the input after form submission via $input, and then fill in "fields" of a "page" (which translates to "columns" of a "record").  Is this correct?

Now, what I am not sure of, is how to add a new page this way (i.e. insert a new record).  Do I need to prepare a template and then use $templates->save($template)?  Is there a short example somewhere of how this works?

Thanks!

...

Link to comment
Share on other sites

Hi and welcome 3dots.

You are on the right track, but not fully. Some hints may be:

To build a form for the front end, you also can use the PW API: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/

How to create a page is in the DOCs or in the forums many times, I believe: https://processwire.com/talk/topic/352-creating-pages-via-api/

Follow SOmas tut with the simple forms creation and do not forgett to use the validation and sanitizer.

Have a look at the Docs and at the cheatsheet, too :) And have fun :)

If you have any further questions after reading and testing, come back and ask.

  • Like 3
Link to comment
Share on other sites

Welcome to the forums, 3Dots!

It seems like you got everything right. In PW you almost always deal with the API which creates pages, not with the database directly.

This is the best post ever about the form api: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/...

...Ahh, no need to write any further - horst got it all!

Edit: But I'll add a link worth exploring: http://store.di.net/collections/software/products/processwire-form-builder. It is an easy form creation module from ryan himself. With it you can create pages from form submissions in no time.

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

Hi and welcome to processwire

You can even use "a page" to store the data of the form fields, use the api to select "the page" that holds the php that will process the form. Follow these threads and you will be making forms in no time:

https://processwire.com/talk/topic/2089-create-simple-forms-using-api/
https://processwire.com/talk/topic/407-processing-contact-forms/#entry3208
https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/page-3
 

Link to comment
Share on other sites

The best way I've found to understand it all (apart from asking questions on here) is to create a test site, create a few pages, templates and fields and then to have a look at the database structure via phpMyAdmin. You will quickly understand what a page, field etc actually is, and you will also realise how simple and efficient PW is behind the scenes.

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...