Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CFForm vs Form in Coldfusion

I have been using plain forms and input fields in coldfusion for some time now but recently discovered that cfinput tags will automagically prevent some xss attacks for me. This has made me wonder, if there is any disadvantages to using cffrom and cfinput over normal form and input tags in coldfusion.

The only disadvantage I have found in the short time looking into it is that it adds 2 external style sheets and 1 script tag to the page.

so in short:

What are the advantages and disadvantages of using CFFORM over FORM in coldfusion?

like image 748
corymathews Avatar asked Jun 07 '11 19:06

corymathews


People also ask

What is form in ColdFusion?

ColdFusion forms tags provide the following features: Built-in validation support You can validate data in the client browser or on the server. You can specify that a field is required, contains a specific type of data, has a maximum length, or is in a range of values.

How do I submit a form on ColdFusion?

The common way to submit forms in ColdFusion is to use a Form Page, where you enter or select data, and an Action Page, where the result is displayed. By using the <cfif> tag with the IsDefined function, you can combine those two pages into one.


2 Answers

I prefer to write my own JS around my forms. I started out with cfform back in the day, but eventually wanted to do more robust things (validations, etc) than cfform was able to handle. That forced me to learn JS, and I've been very happy writing my own JS since.

So I guess I'd say one big drawback is that you're restricted to what cfform can handle. Depending on your situation, that might be fine.

Another drawback that I ran into a long time ago (which to be fair, may have been addressed since), is that the JS generated by cfform would conflict or interfere with my hand-written JS.

It'll certainly come down to preference. It's neither "right" nor "wrong" to use cfform or regular forms. For me, I prefer to be able to do whatever manipulation I need to do manually, as there are no restrictions/limitations.

like image 65
charliegriefer Avatar answered Sep 18 '22 23:09

charliegriefer


I have a love-hate relationship with <cfform> & <cfinput>.

To have the same xss protection that CFFORM provides, just wrap htmlEditFormat() around value="" in regular like so:

<input name="x" value="#htmlEditFormat(x)#">

For even better XSS protection, use OWASP Enterprise Security API (.jar included in one of the CF9 latest hotfixes)

I love how I can do ajaxified form easily without writing JS, but I hate how it generates lots of ugly JavaScript and loads up lots of JS and css files for something rather simple. So I've decided to use cfform for internal sites only and not for public facing site (performance issue).

Other then the ajax features, the checked attribute that accepts CF boolean and populating select with query object are features that cfinput and cfselect provide which can be quite useful.

Use the right tool for the right job. If you found the feature of <cfform> useful, use it. Just know its limitations, and decide for yourself.

like image 44
Henry Avatar answered Sep 18 '22 23:09

Henry