If you would like to use script in your forms in order to automatically flag mandatory fields, using a red asterisk (*) in their captions, check-out this article I just posted on my blog.
The script supports mandatory fields with the following characteristics:
- have plain or rich text captions
- have no captions (no asterisk is displayed in this case)
- use text objects (plain or rich text) as captions instead of normal field captions
- have the same name (multiple instances that aren’t dynamically generated)
- are inside repeating subform instances
Typically called when the root subform is initialized, the script will search recursively (depth-first search) for all fields within a specified container (i.e. the root subform) and will place the asterisk on any mandatory field it finds. There is also a function by which the asterisk can be toggled on/off by explicitly telling the function whether to treat the field as mandatory or optional.
The script is located in a script object. The idea is that you would make a script object fragment out of it and re-use it in any form that needs this functionality. The script is also heavily commented so it should be relatively easy to extend for your own needs.
I found myself suggesting this as a possible solution on another thread today and thought it could be generally useful.
Here’s how you would use the CM API to create a new generic form resource, stuff your form template content into it and save it to the LiveCycle Repository using the currently-posted release:
private function onBtnClick(event:Event):void
// create a new generic form template resource object
var xdp:CmObject = new CmObject();
xdp.resourceType = CmResourceType.FORM_TEMPLATE;
xdp.path = "/cm/content/myForm.xdp";
xdp.contentType = "application/vnd.adobe.xdp+xml";
xdp.contentData = '<xdp><template><subform name="root"><subform name="page"><field/></subform></subform></template></xdp>';
// make sure there's an active, authenticated session
// (note that username, password, server and port are variables you would supply)
if (CmSession.getInstance() == null || !CmSession.getInstance().authenticated)
CmSession.createInstance(username, password, server, port);
// get an instance of the LC Repository
var rep:ICmRepository = CmRepositoryFactory.getInstance();
// save it in the LC Repository
rep.save(xdp, true, onSave, onSaveFault);
private function onSave(event:CmRepositoryEvent):void
Alert.show("Saved XDP to LC Repository");
private function onSaveFault(event:FaultEvent):void
Alert.show("Error occurred while attempting to save: " + event.fault.toString());