Solved

CFML FW1 Declaring Variables

Posted on 2014-01-22
2
244 Views
Last Modified: 2014-01-23
So far what I have is... I think pretty simple. I'm trying to move a legacy system into a FW1 application.

When I run this, I'm getting "Variable POPULATEBODY is undefined."

<cfscript>
	application.cfstatic.include("/js/modules/email/sendemail.js");
	rc.active = "email";
	rc.populatebody = "form.comment"; 
</cfscript>
<form action="" method="POST" name="sendMessage" class="sendMessage" id="sendMessage">
		<input type="hidden" name="sendemail" value="yes">
		<input type="hidden" id="nTierID" name="nTierID" value="<cfoutput>#session.CurrentTierID#</cfoutput>">
  
	<div class="row-fluid">
		<div class="center">
		<h3>Send Email</h3>
       	</div>
        <div class="center">
        	<table align="center">
            	<tr>
                	<td valign="middle" align="right"><strong>REPLY TO ADDRESS:</strong></td>
                    <td><input type="text" name="emailfrom" message="Be sure to include a Reply To address " value="<cfoutput><cfif isDefined('populateFrom') AND Len(Trim(populateFrom))>#populateFrom#<cfelseif isDefined('REQUEST.emailus') AND Len(Trim(REQUEST.emailus))>#REQUEST.emailus#<cfelse>#client.email#</cfif></cfoutput>" size="60"></td>
              	</tr>
                <tr>
                	<td valign="middle" align="right"><strong>SUBJECT:</strong></td>
                    <td><input type="Text" name="subject" value="<cfoutput><cfif isDefined('populateSubject') AND Len(Trim(populateSubject))>#populateSubject#<cfelse>A Message From The Admins</cfif></cfoutput>"size="60" maxlength="200"></td>
             	</tr>
          	</table>
            
         	<p style="text-align:center">
				<br />
				<strong>Your Message:</strong>
				<br />
                <cfmodule template="/assets/tags/editors/richtexteditor.cfm"
                    basePath="fckeditor/"
                    instanceName="comment"
                    height="300"
                    toolbarset="#request.classificationToolbar#"
                    value="#populateBody#"
                    width="95%"
                >
				<br />
				<br />
			       
 	</div>
                      
        
</form>

Open in new window



I guess I do not know how to declare/define variables. What I want to say is this:

if(structKeyExists(form, "comment")){
				populateBody = FORM.comment;
			}else{
				populateBody = '';
			}

Open in new window


But I do not know where to place it within the code... or the controller... or where you begin to declare variables in this manner. Any suggestions?
0
Comment
Question by:traport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 39802983
If this page is expecting certain values to be passes, I think it is good form to show those variables at the top of the page using CFPARAM.  If the values are not required you can add "default" tag, if they are required, you can leave it off.  That way any future developers can easily see what values may be passed to this page.

<cfparam name="form.comment" default="">

<cfset populateBody = form.comment>

This method, IMHO, is much neater than having long <cfif statements inside of your value tag.    Also, in my opinion, you do not want to always have to check to see if a variable is defined throughout a template.    If the template requires it, cfparam it at the top and that's it for the rest of the code.

if the value is required, then remove the "default" tag..

<cfparam name="form.comment">

This will throw an error if form.comment is not passed in..
0
 

Author Closing Comment

by:traport
ID: 39803015
Thanks so much.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question