@Tomek Yes, you could do that. Its simple to create a formtool edit handler that outputs different html depending on the values in arguments.stObject. ftWatch is basically just a way of AJAXifying that dependency.
@nicholas No, no - thank you! I completely forgot to add it to the wizard version. I think there's a ticket for that issue now - could you attach your updated file to the ticket so we can include it in the 5.1 release? On Tue, Feb 3, 2009 at 4:07 AM, nicholas sollecito <[email protected]>wrote: > Ok, I think I'm finally getting somewhere with this. No matter what I > tried, I couldn't get any of the Ajax functions for the dependent selects to > be generated in my Edit form. > So, using the sample cfproperty definitions for Country/State from the > wiki, I created a dummy custom type to get an idea of what mine was missing. > I noticed the javascript listener was being generated for Country/State, but > not for my custom type. I realized the reason for this is that I have a > mult-step wizard, so the tag library being used to do the formtools magic is > in farcry/core/tags/wizard. So, instead of ft:object being called where > addWatch() is executed, wiz:object was being called, where there is no > reference to addWatch and therefore, none of the Ajax goodness was > included. > > I simply copied the addWatch call > from farcry/core/tags/formtools/object.cfm (line @452) > to farcry/core/tags/wizard/object.cfm (line @387) and I'm now getting the > proper javascript listeners as well as dynamic select functionality added > in. Still need to refine to grab the level of categories I need, but this > MAJOR piece of the puzzle is now in place to help me finish this up.. > > Now, this has resulted in me having to make a change to the actual core > farcry tag files which I understand is not ideal... How do I ensure that > this change makes it into the core source (or, if there is a reason it's not > there already, how do I maintain my version of it?). > > Thanks again for your help. > > > > On Feb 1, 2009, at 10:52 PM, Blair McKenzie wrote: > > ftAlias is used by category.cfc (and your own formtool) to specify which > category branch to use. It looks for the specified alias (obviously). This > part of the edit function needs to be changed so that instead of looking for > the branch named with ftAlias, it looks for the branch specified in > arguments.stObject[arguments.stMetadata.ftPrimaryCategory] (I think) which > will be the uuid of the parent category. > > It looks like you will have to create a primarycategory formtool as well if > you want a single level list. To retrieve a single level inside the formtool > use > application.factory.oTree.getChildren(objectid=parentid) > instead of the original > oCategory.getCategoryBranchAsList(lCategoryIDs=rootID) > This will return a query of objectid,objectname instead of a list of > objectid. > > The default ajax stuff is added with the ft:object tag. It basically adds > events to the watched fields. If those other fields change, the dependent > field is ajax'd in. Basically the edit function gets called with the new > watched values passed in. You can see an example of this at work with the > country and state formtools. Neither of them mention ajax, and both work > without it. But if you add ftWatch="countryproperty" to the state property > the state list starts automagically switching when the country is changed. > > On Mon, Feb 2, 2009 at 2:33 PM, nicholas sollecito <[email protected] > > wrote: > >> Ok, so I've followed most of your directions, but I think I'm still >> missing something. Here's what I've done so far... >> >> I've set up the cfproperty for the primary category select as instructed. >> >> For the secondary category, I've taken the "reusable sub-categorisation" >> approach. I've successfully created the secondaryCategory.cfc which extends >> farcry.core.packages.formtools.category. I've copied the edit() method and >> was able to verify through cfdebugging that this is being used for rendering >> the secondary category property. >> >> Now, here's where I'm confused. First, I've added the ftPrimaryCategory >> key to the param'd metadata. >> >> Next, when you say "Set ftAlias to the value of that attribute" I'm not >> sure exactly where you are referring to. By ftAlias, do you mean the other >> metadata params in the edit method (as in arguments.metadata.ftAlias)? Or, >> is this the ftAlias attribute in the cfproperty for the secondary category >> definition? I've added ftWatch to the cfproperty with the name of the >> primary dropdown property. >> >> Also, this may or may not have anything to do with anything, but... >> I've been digging through the formtools code as well as the wiki to try >> and figure this out on my own, but I don't seem to really be getting >> anywhere... It looks like the ajax dependency selects is implemented via >> farcry.core.packages.formtools.field.addWatch(). So, I searched all the >> files to see where addWatch() is being called. Other than a recursive call >> in the method itself, it looks like it's being called only from the >> object.cfm formtools tag. I set up a trace to see how this was being called >> from my custom type and it doesn't appear anywhere. I checked some other >> types and see that it is being called (except from News, which my type is >> based upon). Wonder if this could be one reason why I'm having problems? >> >> Also, I'm looking to just grab just one level of categories. >> Currently, based on the structure below, if I set ftAlias="content" the >> dropdown contains all categories below it. I would like to just get the >> items at the first level beneath "Content". Once a primary is selected, my >> secondary category dropdown would then be populated with the level 3 >> categories. >> >> root >> - Content >> -- Magazine Title 1 (primary) >> --- Column 1 (secondary) >> --- Column 2 >> ... >> -- Magazine Title 2 >> --- Column 3 >> --- Column 4 >> ... >> >> >> Anyway, I hope this is clear. Thank you so much for helping with this, I'm >> pretty new to FarCry but so far I'm very impressed with the potential >> >> -Nick >> >> >> On Feb 1, 2009, at 5:47 PM, Blair McKenzie wrote: >> >> You can have the first item by using ftType="category", >> ftAlias="parentcategoryalias" and ftRenderType="dropdown" (I think). >> >> For the second one, you will probably need to write a custom formtool >> code. >> >> Two approaches. >> >> ONCE OFF CUSTOMISATION >> 1) Add a function named like ftEditYourSecondaryProperty to the custom >> type. Open up core/packages/formtools/category.cfc and copy the arguments >> and code from the edit function into yours. >> 2) Look for where ftAlias is param'd / used, and change the code so that >> the value of the primary property is used instead >> 3) In the cfproperty definition, add ftWatch="primarypropertyname". This >> will add ajax to the form that updates the field when the primary property >> changes. >> >> REUSABLE SUB-CATEGORISATION >> 1) Extend formtools/category.cfc in your project to secondarycategory.cfc >> (or whatever) >> 2) Copy the edit function from category.cfc to your formtool >> 3) Param another metadata attribute ftPrimaryCategory. Set ftAlias to the >> value of that attribute. >> 4) In the cfproperty definition, set ftType="secondarycategory" >> 5) Add ftWatch="primarypropertyname". This will add ajax to the form that >> updates the field when the primary property changes. >> >> On Mon, Feb 2, 2009 at 12:07 AM, nicholas sollecito < >> [email protected]> wrote: >> >>> 5.1 >>> >>> >>> On Jan 31, 2009, at 11:23 PM, Blair McKenzie <[email protected]> wrote: >>> >>> What version of FarCry are you using? >>> >>> On Sun, Feb 1, 2009 at 10:34 AM, Nick S. < <[email protected]> >>> [email protected]> wrote: >>> >>>> >>>> I have a custom Article content type. I would like to use the built-in >>>> categorization in FarCry as a way to apply a Category and sub-category >>>> to the content. Is there a way to implement a dependent select so that >>>> the user must first a Category from a drop-down and then a separate >>>> list box will be populated with the sub-categories to select from? >>>> >>>> I'm currently using form tools and I'm not sure how to further >>>> customize the form to allow for this type of interaction. Let me know >>>> if this is a possibility, I can't seem to find this functionality >>>> either in the wiki or mailing list. >>>> >>>> Thanks in advance, >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> >> >> >> >> >> > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "farcry-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/farcry-dev?hl=en -~----------~----~----~----~------~----~------~--~---
