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

Checkbox values and CF11?

Advocate ,
Feb 11, 2016 Feb 11, 2016

Copy link to clipboard

Copied

I found what I would think is a somewhat big incompatibility between CF11 and all prior CF version: multiple checkbox and select values. If you have multiple checkboxes "checked" that refer to the same variable name, prior to CF11 these came in as a list; in CF11 they come in as an array causing "Complex object types cannot be converted to simple values." My question to Adobe, was this intentional or a bug?

Views

637

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

Guide , Feb 12, 2016 Feb 12, 2016

Do you have a line like line three below at the top of your Application.cfc?

component {

  this.name = "myApp";

  this.sameformfieldsasarray=true;

}

This was a new feature introduced in CF10.  If you want to force the old behavior, change the value to false (or remove it entirely, as the default is false).

Votes

Translate

Translate
Community Expert ,
Feb 11, 2016 Feb 11, 2016

Copy link to clipboard

Copied

Complex object? That doesn't sound like something caused by form field values.

Could you show your code? Then we could throw more eyes at it.

This works for me:

<cfdump var="#form#" >

<cfoutput><form action="#CGI.script_name#" method="post"></cfoutput>

    <input name="chkbx" type="checkbox">

    <input name="chkbx" type="checkbox">

    <input name="chkbx" type="checkbox">

    <input name="sbmt" type="submit" value="Post">

</form>

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
Advocate ,
Feb 11, 2016 Feb 11, 2016

Copy link to clipboard

Copied

I'm using fusebox v5.5.1. Line 8 below is the code that was throwing the exception in CF11, not in CF9 that we upgraded from:

  1. <cfparam name="ATTRIBUTES.UserID" default="">
  2. <!--- CF11 change --->
  3. <cfif isArray(ATTRIBUTES.UserID)>
  4. <cfset ATTRIBUTES.UserID = arrayToList(ATTRIBUTES.UserID) />
  5. </cfif>
  6. <!--- end of CF11 patch --->
  7. <cfif ATTRIBUTES.UserID IS NOT "">
  8.     <cfset ATTRIBUTES.Page=2 />
  9. <cfelse>
  10.     <cfset REQUEST.Msg="No account was selected.<br/>Select account(s) you wish to reset the password(s) for." />
  11. </cfif>

Here is the form:

     <cfloop query="qUserContact">

       <input type="checkbox" name="UserID" value="#UserID#" /> #UserName#<br/>

     </cfloop>

Which translates into one or more input checkboxes:

       <input type="checkbox" name="UserID" value="1" /> Name1<br/>

       <input type="checkbox" name="UserID" value="2" /> Name2<br/>

       <input type="checkbox" name="UserID" value="3" /> Name3<br/>

All the source code and fusebox version level was untouched in the migration. I guess it might not be the direct use of the FORM scope but how fusebox copies from the URL and FORM scope into the attributes scope (structure). In looking at the fusebox code it is doing a simple structappend:

<cfparam name="variables.attributes" default="#structNew()#" />

<cfif isDefined("url")>

  <cfset structAppend(variables.attributes,url,true) />

</cfif>

<cfif isDefined("form")>

  <cfset structAppend(variables.attributes,form,true) />

</cfif>

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
Guide ,
Feb 12, 2016 Feb 12, 2016

Copy link to clipboard

Copied

Do you have a line like line three below at the top of your Application.cfc?

component {

  this.name = "myApp";

  this.sameformfieldsasarray=true;

}

This was a new feature introduced in CF10.  If you want to force the old behavior, change the value to false (or remove it entirely, as the default is false).

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
Advocate ,
Feb 16, 2016 Feb 16, 2016

Copy link to clipboard

Copied

LATEST

Thanks. I did not know about this change or app setting. Learned something new.

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