Questions about forms

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

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:

websiteLogin_redirectToLogin(true);

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!

Thanks,

Daniel
Technical Lead
interactivetools.com

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