Lucee form scope not recognized

206 views Asked by At

The problem below is a puzzle, which I have not solved, but found a way to deal with. I finally tore apart xref2.cfm and put it back together one line at a time. As soon as I did that, the form scope began to work. Nothing changed in the code. So it remains a mystery.

I have a set of 4 procedures which are linked together like this:

person1.cfm: this originates with a call from another program and a url argument basetab=Person . I'm focusing here on the variable "fn".

    <cfif IsDefined('URL.basetab')> 
    <cfset basetab = URL.basetab>
    <cfset perloc  = URL.perloc>
    <cfset fn      = ''>
    <cfset ln      = ''>
    <cfset eof     = "no">

however person1.cfm may also be accessed with a cfinclude further down the line, in which case I rely on the form scope to pass fn back to person1.cfm

   <cfelseif IsDefined('form.fn')>
   <cfset fn      = form.fn>
   <cfset ln      = form.ln>
   <cfset basetab = form.basetab>
   <cfset perloc  = form.perloc>
   <cfset eof     = form.eof>

 </cfif>

however, if neither the URL scope nor the form scope is defined here, the variable fn should have been set in a program which is including person1.cfm, so it should be well defined at this point.

    ... stuff ...
<form action = "person2.cfm" method = "post" ... other stuff>
 <input type = "text" name = "fn" value = "#fn#">
  .... more stuff....
  ... submit ...
</form>      

person2.cfm: this is the next step in the process

   ... stuff ...
 <cfset fn = form.fn>
 <cfinclude template = "person1.cfm"> 
 <form action = "xref1.cfm" method = "post" ... stuff >
   <cfoutput>
   <input type = "hidden" name = "fn" value = "#fn#"> 
   </cfoutput>
     .... stuff ....
     .....submit ....
 </form>         

xref1.cfm this is the next step

   ... stuff ...
 <cfset fn = form.fn>
 <cfinclude template = "person2.cfm"> 
 <form action = "xref2.cfm" method = "post" ... stuff >
   <cfoutput>
   <input type = "hidden" name = "fn" value = "#fn#"> 
   </cfoutput>
     .... stuff ....
     .....submit ....
 </form>

xref2.cfm the final step, where something is done with the accumulated entries

      .... stuff ...
 <cfset fn = form.fn>
 <cfinclude template = "xref1.cfm">
     ... no form ... other stuff ...

The problem is that in xref2.cfm the variable fn is not being picked up in the form scope. Checking things out, I find that form.fn is not defined at all in xref2.cfm. When things cascade back to Person1, fn is not defined and throws an error in the input tag.

form.fn is defined in person2.cfm and in xref1.cfm. But when we get to xref2.cfm, it disappears. I do not understand why. Can someone explain to me why that form scope is not there in xref2.cfm?

1

There are 1 answers

0
Phillip Senn On

I think it was a typo or something.