Previous pageProfiles Next page
Presenting a 'profile form' for user editing 

This page describes a technique to:

  • Provide a logged-in user with a Form where they can enter details about themselves
  • Restricting them to only having one Form record per person
    • If they are new, presenting them with a blank Form
    • If they already have a Form, presenting them with their existing Form

Whilst the example is for a 'profile form' the technique is applicable to all types of scenario, not just 'profiles' - for example providing an application form where the user can return to finish filling it in at a later date.

The heart of the mechanism is a structure arranged like this:

Profile - a Section, visible to the user.

When they want to edit their form, they click on this in the navigation, or are linked to it from elsewhere in the site.

This Section is set to "Redirect to First Child" (BE / Settings / Options). Whilst it would appear that this will always take the user to the "Redirector edit" section, we will see this is only the case if the user already has a profile form record. If they don't, then the 'Redirect to First Child' will take them to "Redirector Add"

Redirector edit - a hidden section.

The important aspect about this section is that in its BE / Settings / General Options / Navigation, it is set to be treated in the navigation not as a single item, but as the 'Output from a Query'. The Query, which we we see later, is based on the Profile Form, and returns an item if the current user has a profile record, or no item if he does not. (Thus, if he does not, there is no 'first child' here for the parent Profile section to redirect to, and it must go to 'Redirector add' instead). In the screenshot below, note the critera in the dialog restricting the query output to the Current User. The Query itself contains links to a Data Entry Form, called 'Edit My Profile', with a parameter set to open it in editing mode.

Redirector add - a section

This section contains a Redirect, set in the Layout Manager, which points to the 'Edit My Profile' data entry form, with parameters set to open in editing mode, and to open a new record:

Note the syntax of the QueryString parameters:

form_19.replyid=-1 - the 19 refers to the page number of the underlying profile Form, the number will likely be different for your site. The -1 means a new blank record should be shown.

& - the ampersand joins the two parameters

action=edit - opens the form in editing mode.

Edit My Profile - a data entry form

This page which the user will be taken to to edit or add their profile information. (For future flexibility it is based on a Form, which is located elsewhere in a hidden admin section.)

Its location as a child of the "Redirector Edit" is not important for the mechanism to work, but makes logical sense.

We need to set permissions to allow the user to access their own record, but not anyone else's. Access to this partof the site will be restricted to users in a particular usergroup, say '"Member':

We need to ensure the user is limited to only one record each. This is done by setting "BE / Settings / Options, Maximum Replies Per User" to 1.

We also need to determine where the user should be taken when they have submitted their Form (BE / settings / Options / Redirect target after record update). If this is set to direct to the 'Profile' section, then the user will be shown their completed Form. Alternatively, it can be set to take them to any other page on the site.

Elsewhere, in the 'admin' part of the site, are two more components: the Profile Form, and a Query used by 'Redirector edit' link to it:

Profile Form - a Form

This can have whatever fields you like on it, however the mechanism requires that you include a User ID field (of datatype 'Username') This does not get shown to the user, but is used by the query:

Q: Link to edit profile - a Query

The Query is based on the Profile Form, and uses a single field, the User ID.

The On-click link for this field is set to the 'Edit My Profile' data entry form, and a QueryString parameter of 'action=edit' is specified, to open the form in edit mode.

On the Link Parameters tab, the Custom parameter selection is used and the Record ID is selected.