• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Reusing CFFORM controls

New Here ,
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

410

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

the include would work if you used a <select> over a <cfselect>. is there any compelling reason to use <cfselect> in this case?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

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 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation