Confused on using ftWatch

20 views
Skip to first unread message

West

unread,
Mar 6, 2011, 4:17:43 AM3/6/11
to farcry-dev
Hi,

I have two properties in my content type. One is called
"accountManager", the other is called "account".

When a user chooses a different account manager from the drop down, I
want the 2nd drop down (account) to change.

Below are the two properties I'm working with.

<!--- Account Manager --->

<cfproperty
ftseq="1"
name="accountManager"
ftfieldset="General Information"
ftwizardStep="Step 1"
type="string"
hint="Account Manager"
required="no"
default=""
ftlabel="Account Manager"
ftType="list"
ftList=":Choose Manager,John Smith,Richard Pickens,Bob Wright"
ftvalidation="required"
/>


<!---Account--->
<cfproperty
ftseq="2"
ftfieldset="General Information"
ftwizardStep="Step 1"
name="account"
type="string"
required="no"
default=""
ftlabel="Account"
ftWatch="accountManager"

/>

In this link, it suggests creating some edit() function basically.

https://farcry.jira.com/wiki/display/FCDEV50/ftWatch+Example

Questions:

1. If I need to create an edit() where do I do this at? Within my
content type I assume?

2. When, how, does this edit() get called?

Regards,

-West

Sean Coyne

unread,
Mar 6, 2011, 9:02:30 AM3/6/11
to farcr...@googlegroups.com
1.  Actually you add it to the formtool.  So in this case, in your cfproperty tag for "account" you will want to specify ftType="string".  Then you will want to extend the string formtool.  You would create a formtools folder in your project's packages folder.  Then create a file called string.cfc, extending farcry.core.packages.formtools.string.  You would add your ftWatch functionality, as shown in the example (though don't use the javascript in the example as the Ext stuff has been removed in favor of jQuery), and be sure to call super.edit() so that core's string.cfc edit method is called.

2. The formtool form will call it when the field is drawn on the form.  By overriding the edit method above, you can add your own javascript functionality that reacts when the form changes.

West

unread,
Mar 6, 2011, 1:41:05 PM3/6/11
to farcry-dev
Thanks for the response.... starting to understand a bit...a few more
questions though... Basically I have two drop down menus, one parent
and one child, based on the selection in the parent, the child should
change.

1. Should the ftType be set to string if I'm trying to use a drop
down?

2. I don't understand how creating this cfc in the packages/formtools
folder is tied specifically to the account <cfproperty> declaration.
How does it know which field? If I had other dependent fields on the
form that also used ftWatch, how does it know which field to map to?

-West

Blair McKenzie

unread,
Mar 6, 2011, 7:39:14 PM3/6/11
to farcr...@googlegroups.com
You can override the edit UI of a formtool by putting a function called ftEditYourPropertyName in the content type component. It will be passed the same arguments as a formtool edit function. In this function you can refer to arguments.stObject.accountManager to generate the data that you output in the list. FarCry will take care of calling this function with the new value via ajax everytime the watched field changes.

In this case I'd say the easiest approach would be:
- set up account as a list property
- add ftEditAccount to the content type
-- override arguments.stMetadata.ftList value depending on arguments.stObject.accountManager (should account for empty-string and isn't-in-struct)
-- return application.formtools.list.oFactory.edit(arguments=argumentCollection)

Blair


--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry

West

unread,
Mar 7, 2011, 12:27:07 AM3/7/11
to farcry-dev
I got it working thanks to your help..thanks to both of you.

On Mar 6, 4:39 pm, Blair McKenzie <shi...@gmail.com> wrote:
> You can override the edit UI of a formtool by putting a function called
> ftEditYourPropertyName in the content type component. It will be passed the
> same arguments as a formtool edit function. In this function you can refer
> to arguments.stObject.accountManager to generate the data that you output in
> the list. FarCry will take care of calling this function with the new value
> via ajax everytime the watched field changes.
>
> In this case I'd say the easiest approach would be:
> - set up account as a list property
> - add ftEditAccount to the content type
> -- override arguments.stMetadata.ftList value depending on
> arguments.stObject.accountManager (should account for empty-string and
> isn't-in-struct)
> -- return
> application.formtools.list.oFactory.edit(arguments=argumentCollection)
>
> Blair
>
Reply all
Reply to author
Forward
0 new messages