farcry

Page 35

UNIT 10 - Building Forms This page last changed on Jun 26, 2008 by mbryant@daemon.com.au.

Objectives After completing this unit you will be able to build your own FarCry forms to edit and save content objects.

Formtool Tag Library Up until this point, all of our forms have been generated for us by the system. But what if we need more flexibility. We must be able to create our own edit forms. FarCry has its own set of tags enabling you to build forms to add, edit and save content yourselves. This tag library is located /farcry/core/tags/formtools and is imported into your webskin using <cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />

We are going to look at this form in 2 stages. 1. Building the Form 2. Processing the Form

Building the Form. The first stage is to simply build the form. The following code is all we need to do <ft:form> <ft:object objectid="#stobj.objectid#" lFields="" /> <ft:button value="Save" /> <ft:button value="Cancel" validate="false" /> </ft:form>

You will see 3 simple tags

Tag - <ft:form /> This tag virtually replaces the html <form> tag. Behind the scene however it is setting up all the nessesary plumbing so that farcry knows what object you are saving, hooks for client side and server side validation and so on.

Tag - <ft:object /> This tag actually renders each of the requested properties in edit mode. All the properties passed through in the lFields attribute will be available for editing. If you want to edit ALL fields, you can leave this attribute blank. This tag also has a number of attributes that you can use to effect the output. Most interestingly is the legend attribute. This will allow you to create your own fieldsets.

Tag - <ft:button /> This tag will provide the buttons to perform actions on the form. essentially replacing the standard <input type="submit" /> html markup.

Source of a sample form Below you will see an example of the generated html markup that the simple form tags we used above actaully generates. Although it looks

Document generated by Confluence on Sep 05, 2008 12:39

Page 35


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.