4 Replies Latest reply on Feb 16, 2016 3:07 PM by Steve Sommers

    Checkbox values and CF11?

    Steve Sommers Level 4

      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?

        • 1. Re: Checkbox values and CF11?
          BKBK Adobe Community Professional & MVP

          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>

          • 2. Re: Checkbox values and CF11?
            Steve Sommers Level 4

            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>

            • 3. Re: Checkbox values and CF11?
              Carl Von Stetten Adobe Community Professional & MVP

              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).

              • 4. Re: Checkbox values and CF11?
                Steve Sommers Level 4

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