Skip to main content
Known Participant
May 11, 2006
Question

using uuid as form field name

  • May 11, 2006
  • 4 replies
  • 881 views
Hi
i am using uuid as field name at generation of dynamic forms from database.
when i try to read form fields, i get following error:
Parameter 1 of function IsDefined, which is now "Form.1CC93A4B-20ED-B6D6-FE1E922BC96AFE1F", must be a syntactically valid variable name.

how i could handle this problem?
i have seen crm systems using uuid, but i dont know how reading of form fields are handled.
i like idea of using uuid because there are unique and therefore same names cannot come i accidentlty to form.

Please, some help would be nice.

Cheers
Kim
    This topic has been closed for replies.

    4 replies

    Inspiring
    May 11, 2006
    > Don't know why no one else has mentioned this. You can't have dashes in form
    > field names.

    I imagine they've not mentioned it because it's not true.

    --
    Adam
    Inspiring
    May 12, 2006
    It's true when trying to read a submitted Form variable in CF. Try this:

    <cfif IsDefined("Form.aa-aa")>
    <cfoutput>
    #Form.aa-aa#
    </cfoutput>
    </cfif>

    <form method="post" action="##?<cfoutput>#CreateUUID()#</cfoutput>">
    <input type="text" name="aa-aa" size="20" value="123">
    <input type="submit">
    </form>
    Inspiring
    May 11, 2006
    Don't know why no one else has mentioned this. You can't have dashes in form field names. You have to strip them or convert them in your form before posting. Here's an example of replacing the dashes with underscores(which are allowed) and adding a preceding number for sorting form field names after the form is submitted. The first routine is to cycle thru the submitted form fields, sort them and Evaluate their value. Hope this helps.

    <cfoutput>
    <cfif IsDefined("Form.FieldNames")>
    <cfset sorted_Field_Names = ListSort(Form.FieldNames,"text","asc")>
    <cfloop index="i" list="#sorted_Field_Names#">
    Form.#i# = #Evaluate("Form." & i)#<br>
    </cfloop>
    </cfif>
    </cfoutput>

    <cfset kounter = 0>

    <form name="x" method="post" action="##?<cfoutput>#CreateUUID()#</cfoutput>">
    1 <input name="<cfset kounter = kounter + 1><cfoutput>#NumberFormat(kounter,'000')#__#Replace(CreateUUID(),'-','_','ALL')#</cfoutput>" type="text" value="1"><br>
    2 <input name="<cfset kounter = kounter + 1><cfoutput>#NumberFormat(kounter,'000')#__#Replace(CreateUUID(),'-','_','ALL')#</cfoutput>" type="text" value="2"><br>
    3 <input name="<cfset kounter = kounter + 1><cfoutput>#NumberFormat(kounter,'000')#__#Replace(CreateUUID(),'-','_','ALL')#</cfoutput>" type="text" value="3"><br>
    <input type="submit">
    </form>
    Known Participant
    May 11, 2006
    also you can use structure functions
    <cfif StructKeyExists(Form,"1CC93A4B-20ED-B6D6-FE1E922BC96AFE1F")>
    do something..
    </cfif>
    Inspiring
    May 11, 2006
    > "Form.1CC93A4B-20ED-B6D6-FE1E922BC96AFE1F"

    Form["1CC93A4B-20ED-B6D6-FE1E922BC96AFE1F"]

    --
    Adam