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.
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
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.
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
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.