Formtools (ftType:state)

I would like to ask which specific content type cfc (entire file syntax) if possible, i could use with the formtool ftType state. It would help me a lot to build an interactive fields form as i am beginner and thus can not figure out what is happening with formtools types, values and getstates function.
According to your farcry book display and edit functions along with default edit.cfm are obvious. Some reverse code engineering in this context definitely would help me a lot!

Regards

Personally I just create my own states and countries methods in a helper cfc and allow it to be returned as an optional array of structs or a query. Super simple to make.

Once in place, I can use it for custom formtools (dropdowns, etc) as well as frontend website needs (I just write a quick array function/closure to search the data, or you could write a simple QoQ).

However, if you want to stick with the builtin state formtool, you could just talk directly to the state object itself and do something similar with that.

Thanks for your concise post but unfortunately i am at beginner’s level.

If you could provide with a specific github example (first method), it would help me a lot especially not to do any errors. I would be interested also to find out (second method), as it was my initial query.
The more i learn, the more i become addicted with Farcry framework.

Regards

Here you go:

  1. https://gist.github.com/jeffcoughlin/9ce9b2e1f29aaf03c967b12753192971
  2. For the second one, just create the object to point to the formtool and talk directly to the methods.

Note: The example getStates() method I use there is for US only. If you want to parse states based on country, you’ll want to factor that data in a little differently (maybe just use the country as a filter for the method and return the appropriate data that way).

Thanks for your great assistance via the detailed example!

One more question, how do i fetch country value in order to use it as a filter for getStates().

Regards

If you were to use the built in state & country formtools you could add a ftWatch=“country” to the state field and it would update the list when you change the country. you could override the built in ones in your project if you needed different countries and/or states.