Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Warning
titleWork in Progress

Updating the course for FarCry 6.x. If you can help let us know! Put your notes in the comments for the page.

Objectives

Excerpt

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

...

This tag is used to capture an event raised by a <ft:button />. You will notice in our form we had a <ft:button value="Save" />. If someone was to click on that button, the "Save" action will be raised and will be captured by the <ft:processForm action="save" /> tag. Any code inside of the tag will only be run IF the [Save] button is pressed.

<ft:processFormObjects />

This is where the action is at. This tag does all the heavy lifting... well saving anyway. This tag says to the framework: if any fields belonging to an object with the objectid of "#stobj.objectid#" has been submitted by a FarCry form, then save the values of those fields to the object in the database.

...

  1. Paste the following code below the <cfimport /> tag but above our form:
    Code Block
    <!--- Form processing --->
    <ft:processForm action="Save">
    	<ft:processFormObjects objectid="#stobj.objectid#" />
    </ft:processForm>
    
  2. Now go and edit a Super Hero and this time when you press Save, notice that your data has, in fact, been saved
  3. Great, but when we hit Save or Cancel, we don't actually just want to keep refreshing the page; we need it to exit out to where we came from or wherever the calling page tells us to go
  4. Paste the following code below our current <processForm /> tag
    Code Block
    <ft:processForm action="Save,Cancel" exit="true" />
    
  5. Now go and save your Super Hero and see what happens

Bonus Lab: Building Forms in the Front End

In addition to changing the default behaviour of forms in the webtop, its also possible to build forms using formtools directly in the front end of your website.

  • Build a type webskin listing content items of a particular type
  • Put in an "ADD" button and link to a type webskin for adding new content (eg. displayTypeAdd.cfm)
  • Create a temporary session object using the "key" attribute so you don't have to create a database record every time someone just views the form
  • Call a custom edit handler to update the new record
  • Process the form POST and redirect the user to your type listing page