Skip to main content
Participating Frequently
January 6, 2009
Question

<form> with CF expression

  • January 6, 2009
  • 2 replies
  • 367 views
Hello to ALL!!!
I'm going to use <form> in my CF application
For instance, if I type:
<cfscript>
myvar="hello";
</cfscript>

<form>
<input type="text" value="#myvar#">
</form>
I have to use <cfoutput> so, the right code will be:
<cfoutput>
<form>
<input type="text" value="#myvar#">
</form>
</cfoutput>
In other words, I'd like to say, that if I want to use CF expressions inside <form>, I'd ALWAYS have to insert my form inside <cfuotput> tag, am I right???

The question arises, because I've read some "best practice" with some optimization ideas: don't use CFForm or don't use CFSET or CFOUTPUT.
Thanks for your answers!!!


This topic has been closed for replies.

2 replies

Inspiring
January 6, 2009
vovasvv wrote:
> The question arises, because I've read some "best practice" with some
> optimization ideas: don't use CFForm or don't use CFSET or CFOUTPUT.
> Thanks for your answers!!!
>

Firstly, if you don't use CFOUTPUT nothing is output and that is
probably not desirable. I suspect that the optimization idea was not to
*overuse* CFOUTPUT. I.E. don't do something like this:

<cfoutput>
<!--- 13000 lines of code ---->
</cfoutput>

But rather only put the <cfoutput> tags around content that is meant, ya
know, to be output.

Secondly, that advice sound very out of date and may be from the pre-MX
days of ColdFusion 4.x and 5. Since ColdFusion was ported to a Java
base in version 6.0, the <cfset...> advice is generally not true any
more as it usually generates the same Java byte code now.
Inspiring
January 6, 2009
"Best Practices" are a matter of opinion. My way is not necessarily the best, but the way I code is:

1. I use cfform/cfinput/cfselect with no reservations.
2. If I am going to set more than one variable, I use cfscript. If just one, I use cfset. The issue is code readablility and the amount of typing.
3. I use cfoutput when necessary.

It might be relevent to know that I code intranet applications and as such, don't have to worry about users disabling javascript of turning off cookies.