• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Accessing form fields with [brackets] in the name

Community Beginner ,
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

Wondering if anyone has ideas for accessing form field values when the fieldnames include brackets like the ones in the cfdump of a form post shown below (it’s a MailChimp webhook)?

When I try to access the values using #form.data[list_id]# for example, I get a ColdFusion error, I’m guessing because it thinks I’m trying to access an array element. Any help appreciated.

struct

DATA[LIST_ID]

000000000

DATA[NEW_EMAIL]

foo@bar.com

DATA[NEW_ID]

000000000

DATA[OLD_EMAIL]

foo@bar.com

FIELDNAMES

TYPE,FIRED_AT,DATA[NEW_ID],DATA[NEW_EMAIL],DATA[OLD_EMAIL],DATA[LIST_ID]  

FIRED_AT

2010-03-08   17:49:09

TEMPID

[empty   string]

TYPE

upemail  

TOPICS
Advanced techniques

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 08, 2010 Mar 08, 2010

One can access struct members either via dot-noation if the keys are "valid variable names", or via bracket notation, eg:

myStruct["myKey"]

Using bracket notation does not have the valid-variable-name restrictions that dot notation has.

--

Adam

Votes

Translate

Translate
LEGEND ,
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

One can access struct members either via dot-noation if the keys are "valid variable names", or via bracket notation, eg:

myStruct["myKey"]

Using bracket notation does not have the valid-variable-name restrictions that dot notation has.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

So in the case of my example the correct syntax would be

#form["data[list_id]"]#

correct?

Thanks,

Chris

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

LATEST

Sure.  Easiest way to find out is to try it...

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation