Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / June 2007



Tip: Looking for answers? Try searching our database.

Reusing CFFORM controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ForumUser - 28 Jun 2007 19:37 GMT
I'm wondering if anyone has a solution for reusing form controls. Let's say I
have a specific <cfselect> for states that I want to use in 200 different
forms. Of course I can copy/paste it all over the place, but that's bad
software development. I'd like to be able to put that CFSELECT in a separate
file or function, and just call it.

Here's and example of what I'm trying to do:

file1.cfm:
<CFFORM ...>
<CFINCLUDE tample="StateSelector.cfm">
</CFFORM>

StateSelector.cfm:
<CFSELECT ...>
...
</CFSELECT>

I constantly get the error message "The tag must be nested inside a cfform
tag", and I can see why. But that's very limiting when you're designing large
systems with CF. Has anyone found a way to do this? It doesn't have to use
CFINCLUDE. Any method to allow code resue is fine.

Thanks in advance.
[CJ] - 28 Jun 2007 19:44 GMT
the include would work if you used a <select> over a <cfselect>.  is there any compelling reason to use <cfselect> in this case?
ForumUser - 28 Jun 2007 20:33 GMT
I want to be able to take full advantage of CFSELECT, CFINPUT, CFCALENDAR, etc.
CFSELECT was just used as an example.  It'd be nice if I can setup different
CFINPUTS and just reuse them in different cfforms.  But CF doesn't allow
CFINPUT anywhere outside of a CFFORM.  So, for example, I can't put CFINPUT
inside a CFFUNCTION, and call that function 10 times within a CFFORM.  So
standardization and code reuse is not an option.

The same problem goes with CFFORM itself.  It does not seem to be extendable.  
For example, I cannot find a way create a custom tag called MyCFFORM that would
embed a CFFORM in it.  CF wont' let you put a CFINPUT between MyCFFROM tags.

So my question is, is there a way to maybe go under the hood, and extend
CFFORM, CFINPUT, CFSELECT, etc?  Hope it makes sense.
[CJ] - 28 Jun 2007 22:09 GMT
personally, i don't use cfform.  comes from way back in the day when the cfform
generated JS would stomp the JS that I wrote myself.  i hear it's gotten
better... but old habits and all that.

as far as taking full advantage of <cfform> and its child elements... you
might want to look into some of the JS libraries like jQuery.  I believe that
it'll offer the same type of functionality that you're getting from cfform (and
then some).  not to mention that it's easy to extend yourself, as the library
files are just .js

this way you won't be bound by the inability to create modular pieces by the
fact that ColdFusion won't allow the cfform elements to be broken up.

just a suggestion.  i'm sure there will be others :)
ForumUser - 28 Jun 2007 23:23 GMT
I agree, and I haven't been using CFFORM for the same reasons.  I just need to
use its Flash and XML capabilities.  CFMX 8 is introducing more exotic form
elements that are hard to pass on, but CFFORM doens't work with my current
framework.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.