Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

FarCry detects that a component exists but hasn't got a corresponding persistence model in the database - the "deploy" options creates all the tables required for this content type. The columns are mapped to their relevant data types, depending on the FarCry data type nominated and the specific relational database you are using.

Tip

FarCry 5.x supports mySQL, MS SQL, Postgresql and Oracle.

...

Info

The integrated FarCry ORM differs from other frameworks that might ordinarily rely on the database schema for metadata, for example Reactor and Transfer. Typically these frameworks will generate components to manage interactions with the database. In contrast, FarCry generates a data schema to manage the data represented by its components.

FarCry relies on the component to define the required data model definition and has tools to keep the database model in sync with changes to the component property set. Not only will the framework deploy tables it will also alter columns and data-types to match changes in the underlying component as required. The COAPI is even clever enough to set precision on table columns and build indices for better performance.

All properties in the component map to a specific column in the content type table, with the exception of array properties (discussed later on).

Missing: notes on
Warning
Tip

types is an abstract class that contains a number of system attributes/properties inherited from types required.that are inherited by any custom content type.

Warning

Walkthrough: Creating Super Hero

We'll kick off our sample application by creating a content type for the Super Hero.

  1. Create a new file called superHero.cfc and save this into your project's ./packages/types directory.
  2. Copy the following code into this file, save and review with the instructor
    Code Block
    
    <!--- ./packages/types/superHero.cfc --->
    <cfcomponent name="superHero" extends="farcry.core.packages.types.types" output="false" displayname="Super Hero">
    
    	<cfproperty
    		name="title" type="string" default="" hint="Super hero title." />
    	<cfproperty
    		name="secretHideout" type="string" hint="The secret hideout location of the super hero" />
    	<cfproperty
    		name="teaser" type="longchar" default="" hint="Mini intro for super hero biography." />
    	<cfproperty
    		name="biography" type="longchar" default="" hint="Super hero biography." />
    	<cfproperty
    		name="imgHero" type="string" hint="The image of the hero" />
    
    </cfcomponent>
    
  3. Go to the FarCry Webtop and deploy the content type: ADMIN > Developer Utilities > COAPI Tools > Types
  4. Locate your new content type, "superHero" and select DEPLOY.
  5. Click on the [Scaffold] button now to create an Administration scaffold
  6. Select the checkbox next to "Create type admin interface",
    1. put in a title for your administration list
    2. select label and imgHero as the fields to appear in your list
      Info
      titleBasic Scaffolding

      The Scaffold option for deployed content types generates some sample code you can use to get started right away.
      "Create type admin interface" creates a small XML file that generates a menu item for you in the FarCry webtop.
      The framework provides a default edit handler and display view so no need to add anything else here just yet.

  7. Reload your Application. This time you will need to update the [Webtop] option
  8. Go to the Content Tab. Locate your Super Hero admin and create some Heroes (or Villains!)
    Info
    titleEditing Content Types

    When you created your first superHero object you may have noticed a rudimentary edit handler allowing you to key in details, save and update. That's not actually part of the scaffold code that was generated at all. The edit handler is dynamically generated at run time based on the metadata associated with the superHero component's cfproperty tags. Ok. So its pretty minimalist now but wait.. it's only the beginning.

    Warning
    titleWait Up!

    Make sure you understand the concept of extends, displayname and property type before the instructor starts babbling on about something else.

Formtools

Formtools is essentially a library of clever UI controls that react dynamically to the metadata encapsulated in your content type definition.

There's an extensive number of configuration options for every UI control. You can bypass FarCry's automated layout engine and hand code your forms using the controls if required. You can also override the behaviour of the default controls or create your own controls entirely.

So without going into the detail behind how formtools works - what's in it for the FarCry developer? Well most of the time you will never have to build an administration interface for your content types. Seriously.

Next we

...

will extend our simple superHero

...

content type to leverage these

...

"formtool" features.

...

We'

...

re focusing on a selection of the individual property tags in superHero.cfc for the sake of brevity so be sure to fill in the gaps.

Check out the code sample on this page, and pay particular attention to the attributes starting with "ft".

Code Block

<!--- ./packages/types/superHero.cfc --->
<cfcomponent name="superHero" extends="farcry.core.packages.types.types" output="false" displayname="Super Hero">

	<cfproperty
		name="title" type="string" default="" hint="Super hero title."
		ftSeq="1" ftFieldset="General Details" ftLabel="Title" />
	<cfproperty
		name="secretHideout" type="string" hint="The secret hideout location of the super hero"
		ftSeq="2" ftFieldset="General Details" ftLabel="Secret Hideout" />
	<cfproperty
		name="teaser" type="longchar" default="" hint="Mini intro for super hero biography."
		ftSeq="3" ftFieldset="General Details" ftLabel="Teaser" />
	<cfproperty
		name="biography" type="longchar" default="" hint="Super hero biography."
		ftSeq="4" ftFieldset="General Details" ftLabel="Biography"
		ftType="richtext" />
	<cfproperty
		name="imgHero" type="string" hint="The source image to upload"
		ftSeq="10" ftFieldset="Imagery" ftLabel="Hero Image"
		ftType="image" ftDestination="/images/superHero/imgHero" ftImageWidth="120" ftImageHeight="120" ftAutoGenerateType="fitInside" />
</cfcomponent>

Form Layout

By modifying the ftSeq and ftFieldset attributes we can order form fields and group them into specific field sets. Every field sharing the same fieldset value will appear in a correctly formatted field grouping in the edit handler.

Tip
titleftHelpTitle and ftHelpSection

If you are feeling really adventurous you could add ftHelpTitle and ftHelpSection to the very first cfproperty of each fieldset and you'll get a nicely formatted inline help message allowing you to describe what the fieldset is all about.

...

Attribute

Description

Value

ftType

Type of form control

Defaults to the type value

ftLabel

Text label for the form element

Defaults to property name if absent

ftShowLabel

Flag to show/hide text label for the form element

Defaults to true

ftSeq

Numeric value for form field display order

No default value

ftFieldset

Text used as a title to group a set of fields

No default value

ftWizardStep

Allows you to create multi-step forms; set to the title of the step as you would ftFieldset

No default value

ftStyle

Inline style to apply to form element

No default value

ftClass

Class to apply to form element

No default value

ftDisplayOnly

Boolean that prevents the field from being editable

Defaults to false

ftDefault

Default form field value

No default value

ftDefaultType

The type of default value: "value", "expression" or "evaluate"

Defaults to "value"

ftHelpTitle

Title of a fieldset-related inline help section; only works on the first property in a fieldset

No default value

ftHelpSection

Section text for inline help related to fieldset; only works on the first property in a fieldset

No default value

ftValidation

A comma-separated list of validation requirements

No default value

ftHint

A small inline hint that appears below the field to assist users

No default value

Formtool Validation

updated validation options to reflect shift
Warninginfo
titleThis needs to be updated!
Client Side Validation Uses jQuery Validation Plugin

Client side validation options reflect the move to jquery/jqueryui as the standard UI for the webtop

...

ftValidation with a comma separated list of validation requirements.

...