Questions about forms

5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 3, 2022   (RSS)

By andreasml - December 27, 2021 - edited: December 27, 2021


I am trying to set up a form for adding a new record in a section or editing existing records from this section. The name of the form is "various-form.php" corresponding to the section named "Various". I come across the following issues:

1. I have ticked the "Allow editing existing records (advanced feature)", but when I load the "various-form.php" file I can only see the "Add record" option. I cannot find any link to edit any existing records. Is it something I should do? Is it possible to have a table with a list of the records I have created (i.e. name, date, etc) and choose the one I would like to edit from this list?

2. I have ticked the "Require users to be logged in (requires Website Membership plugin)", and when I open the page ("/various-form.php") I get back the message "You must log in to use this form!". Instead of just a simple text message I would prefer to have a link sending the user to log in or the log in form from the Website Membership plugin. Is it possible to do it?

3. Each form (i.e. "various-form.php") is created in one single page containing all the fields of the section, and at the bottom of the page there is the button "Submit". For the user's facilitation, I think it would be better to be able to split the form into smaller form-subsections, each one connecting to the next or previous one with a "Next" or "Previous" button at the end of each form-subsection, leaving the "Submit" button for the last form-subsection. In other words, to create a multi-page form. Is it possible to divide the form into smaller form subsections and create a multi-page form and how can it be done?

Thank you in advance, and best wishes for 2022!!

Andreas Lazaris

By daniel - December 31, 2021

Hi Andreas,

1: To use the form to edit a record, you need to specify the record num in the URL, e.g. "various-form.php?num=123". A simple way to have a list of all entries with edit links would be to create a List Page for the Various section, and generate an edit link something like this:

<a href="various-form.php?num=<?php echo $record['num']; ?>">Edit</a>

2: You should be able to replace that message with the following Website Membership function to redirect to the login page:


3: There isn't a simple built-in way to achieve this multi-page submission style. One way I can think of that may work is, if you have knowledge of JavaScript, to create a script that shows/hides portions of the form as the user completes it, then submits the form after the last section is complete.

Let me know if you have any other questions!


Technical Lead

Hi Daniel

Thank you for you help. All your advice works great.

By the way, I just noticed that when I create a viewer list page I get back all the records stored in the section. I would expect to get back only those ones that have been created by the specific user who asks it, as it happens when the user logs into the CMSB. Is it something that can be done?



By daniel - January 3, 2022

Hi Andreas,

As Jerry says, to load only records created by the current user, you'll need to filter using the createdByUserNum field. The most simple version would just be adding something like this to the getRecords options:

'where' => mysql_escapef('createdByUserNum = ?', $CURRENT_USER['num']),

Note that there are some cases where this might not work as expected depending on your Website Membership plugin config (e.g. using a different member table than default) but if users are both adding and viewing the entries on the front-end this should generally work just fine.

As well, this doesn't account for any permissions - if you want particular users to be able to view all records that would require some additional logic.

Let me know any other questions!


Technical Lead