Frontend form data to new page?

Hello.

I’m seeking a little direction (maybe a detailed map if possible) from you good folks. How I can save data from a front end form as a page? The form will need to create a new “page” for each submission.

Maybe saving the data as a page isn’t the most efficient route? Maybe I should save the data to some other format? I’m open to ideas.

Hey there !
I think this post will give you a detailed map of how to efficiently achieve this :

You would have to use $pages->create() instead of $page->update(), of course. Also, do you want anyone to be able to create a page, or only logged in users?

What do you want to achieve? What sort of data do you want to save?

Thanks for the response. The web project calls for a number of short forms that collect basic contact information. That data needs to be saved so it can be viewed and sorted and exported into a CSV.

I’m surprised no one has created a plugin for this. Don’t get me wrong. I prefer to custom build solutions but I’d rather not reinvent the wheel.

There is a comments plugin by @addpixel, which creates subpages from frontend data, you may check that out as a starting point: https://github.com/Addpixel/KirbyComments

To answer you question, anyone can submit data.

Thanks for that. Thinking ahead… are there any built-in features/methods to filter how pages are listed within the panel? I’d imagine I need a tidy list that shows date of submission, name, and maybe one more piece of data that could be filtered.

No, there are no built-in methods for filtering. You can only sort pages in the subpage list, not filter them. Maybe something like that is possible with the subpage list by @flokosiol, but I haven’t checked that out yet.

As an alternative, you could implement that list on the frontend and provide a link to each page in the panel for easy editing, if necessary.

If I knew what was good for me I’d build this with WP and implement Gravity Forms but I would indeed feel less satisfied with my work. Just thinking about how Gravity spits out the HTML makes my stomach tighten up (but really the client couldn’t care less).

Despite my passion to learn and build things from scratch there’s only so much time I can put into it before it becomes unwise.

Nonetheless I’ll continue to poke around and see if I can materialize my vision piece by piece with the help of Kirby and its crew.

I really hope you find a way to make this work for you. I’d love to see it working !

There are some filter options for the subpagelist field, but this must be configured in the blueprint. It’s not possible for backend users to filter (like with form inputs).

Subpages are displayed the same way as in the sidebar, because I’m using the core snippet as it is. But you can adjust the template by modifying the plugin as described here

I’ve built a tiny newsletter subscription form that saves data to a structure field in the panel. It works pretty well (albeit I need to add try { … } catch { … } logic

Here’s the back-end in the panel:

If you’re interested, I can share my code after polishing it a bit :wink:

1 Like

Hi Thiousi,

Interesting. I like the idea of saving data to a structure field. It seems more tidy (less files involved among the collection of submissions). And I can image how fairly easy it would be to, at the very least, offer a link to generate a csv file of the data. This is especially good in your case where you’re collecting only a few pieces of data per submission.

Thanks for offering to share your work. I’d be greatful. In return I’ll buy you a shirt and a beer. :grin:

1 Like