Jump to content
Vineet Sawant

Form processing on front-end, dynamic forms and creating page

Recommended Posts

TL;DR : I'm looking to create dynamic forms which will take fields list from given template & create/save pages dynamically.


I've been using PW for a while for creating web applications like ERP systems and similar applications which have tons of forms.

So far I've been creating, processing & validating them manually. While researching I found this link which I found to be very helpful.

Code given in that example allows user to create a form based on the fields of any page and save it, which is very cool.

Based on that code I tried doing something like this:

$p = new Page();
$p->template = "mytemplate"; //I've added few fields to this template
$p->parent = "/someparent/";

// make a form
$form = $modules->get('InputfieldForm');
$form->method = 'post';
$form->action = './';

// add the page's fields to the form

// add a submit button to the form
$submit = $modules->get('InputfieldSubmit'); 
$sumit->name = 'submit';

// process the form if it was submitted
	$p->name = date(dmYhisn);

It did create a page but without any data. I know this could be a very stupid thing to try, but I guess it was worth it.

More research taught me that probably using ProcessPageAdd module I can create new pages. But I don't know how exactly that works.

I'm looking for some guidance about modules & their use on fron-end.


Share this post

Link to post
Share on other sites

I write a module FormHelper to create Frontend forms Form page, template vor array oft field data.


Next module will be a frontend content manager (edit and create pages based on FormHelper module).

Hi, your module looks great. Can I use it for any kind of template? Cause the forms I want to process can be of any size, mostly they'll have tons of fields.

Also, is it published? I'd love to give it a try.

Thanks a lot.

Share this post

Link to post
Share on other sites

It isn't tested with multi language fields or something like repeater fields at the moment.

You can generate a form based on saved pages and get a prefilled form as default. 

Create a form from template fields works with a "fake page" (created but not saved page object), but so you can't use a template with image / file fields that way. You'll get an error message. Maybe it works if the fake page gets saved before the form is generated. I'll see during page add funtion of planned frontend content manager (instead of use a template based form the module create and save the needed page before generate the form via FormHelper.

For use with me UserLogin module the third way was added. The login form is defined as data array. Should be the same problem with image / file fields, but haven't tested it...

I puplished the module code at the last topic post, but not released a module as yet...

Module will be released after code cleanup, but it isn't tested enough to be stable!

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By LAPS
      I opened a new wishlist topic on the PW forum for this and in the meantime I ask to the community looking for a reasonable solution.
      Using the PageTable field, is there a way to un-restrict the creation of pages under a given parent template page (or as page children if no parent for items is selected)? That is, is there a way to allow the selection of the parent page dynamically / on the fly during page creation via the PageTable field?
    • By LAPS
      I'm using the PW PageTable field extensively and I think an improvement to it could be made regarding the ability to choose the page parent where the page created via PageTable will reside.
      Say you have a PageTable field set like this:
      Edit Field: page_table_field > Details >
      Select one or more templates for items
      > template_one
      > template_two
      > template_three
      Select a parent for items
      > parent_template
      Actually, you can only create pages under the parent_template page (or as page child if no parent for items is selected).
      BTW I am looking for reasons about this limitation.
      What about allowing to choose on the fly where the pages created via PageTable will reside? that is, having the possibility to choose dynamically under which parent page to create the pages?
      Actually, one could overcome to this by creating multiple appropriately set PageTable fields, one PageTable field per PageTable parent for items, but this is unsustainable (?) when you want to create a lot using PageTable…
      By allowing to choose dynamically / on the fly the parent page during page creation via the PageTable field would open up a wider usage of PageTable.
      What do you think about?
      @ryan @Robin S
    • By ngrmm
      My clients wants a modal to show up on every page. But when a user clicks inside the modal -> a session-cookie is set and the modal gets a class.
      // user clicks on modal button $('.modal_button').click(function(){ // 1. set PW session cookie // 2. toggle class $('.modal').toggleClass('off'); }); I know how to set a cookie on page-load via PW-API. But the click on the modal button does not force a page-load. So i have to set the cookie through javascript. Is there a way to do that?
    • By VeiJari
      I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array.
      $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON.
      Is there something I'm missing?
      Thanks for help
    • By VeiJari
      Hi, this is the first we are trying to make a page that has only one type of user that has access to every page. 
      The other users should only have a given access to specific pages, not to the whole template.
      My structure
      -Field -Organisation -Project -Report I want that the "measurer" role only has access to "project x" and it's children, but no view access to every project, organisation or field. I've tried to do this with https://modules.processwire.com/modules/page-edit-per-user/ but it still needs a view access to the whole tree to see the "project x" page. Or is there something I haven't figured out?
      Maybe I have to make it via the API: a select field in the "organisation" template where the admins could add the users and then I use hook to update the privileges?
      Have you done something like this and how did you accomplish it?
      Any help would be appreciated.
  • Create New...