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

Hi

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 andreasml - January 1, 2022

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?

Regards, 

Andreas

By gkornbluth - January 2, 2022

Hi Andreas,

To accomplish what you're asking you can use the createdBy function built into CMSB to return only those records created by the specific user who is logged in at the moment.

Do a search for createdBy in the CMSB Cookbook > 'Subscribers Only' > 'Access the complete cookbook' and you'll find a number of examples that can be easily modified to give you the result you're after.

Hope that helps and have a safe, healthy and prosperous New Year

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

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!

Thanks,

Daniel
Technical Lead
interactivetools.com