Just recently I've worked on a couple of sites that needed sign-up forms for new users. You know the kind - enter your details, along with a username and password, before agreeing to some T&Cs and submitting the request. Nothing ground-breaking really.
However, there's a problem with these forms — the legalese text of the terms and conditions. You know what they'e like; going on and on and on endlessly. With this in mind I ended up wondering what was the best to way to store them in our Form?
- Enter the text straight on to the form.
- Store the text in a configuration document and fetch it via an @DBLookup.
The first option isn't really suitable as the text changes and, as we all know, design and data should never be mixed. The second option is better, but it limits the amount of text the legal department can use. Probably a good thing but they just won't have it!
What we need is a way to store as much text as they can produce and import it in to the sign-up form. To do this we need to store the text in a Rich Text field. How so?
What I've come up with is a elegant hack to import some read-only Rich Text in to a new form in edit mode. The rich text is stored in a separate document. First thing to do is fetch it using the WQO agent:
Set vContractsView = vThisDatabase.GetView("Agreements") Set vContractDocument = vContractsView.GetFirstDocument Set rtitem = vContractDocument.GetFirstItem( "Body") Call rtitem.CopyItemToDocument( vWebDocument, "Agreement")
This copies the Body field from the contract document to the Agreement field on our signup form. Now, the Agreement field is Rich Text, which, by default, will appear as a TEXTAREA element containing unformatted text. Although the form is in edit mode we want the field to be in read mode.
My first attempt to make it read only was to make the Agreement field computed, referencing itself as the computed value. This doesn't seem to work in combination with the WQO LotusScript though (anybody know why?). Instead I turned to a design element I've not used for about 6 years — the Controlled Access Section.
Notice the Agreement field is inside a (untitled) section. The access formula for this section is "no-one", meaning that only a user called "no-one" can edit the fields inside it. Assuming that's not the user's name then this makes the field appear as read-mode text. Et voila - limitless amounts of user-configured rich text on a form.
Update: I added a second demo form to the database which demonstrate's Peter LaComb's more elegant approach, described in the comments below (basically you delete the computed RT field using the WQO agent, before creating a new one).