tracker issue : CF-4204458

select a category, or use search below
(searches all categories and all time range)

sameFormFieldsAsArray results in array like object not real array

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Bob G. / ()

Created: 05/28/2019

Components: Application Framework, PerAppSettings

Versions: 2018

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2018.0.03.314033 / CF2018U5

Priority/Frequency: Critical / Some users will encounter

Locale/System: English / Other

Vote Count: 0

sameFormFieldsAsArray results in array like object not real array

Problem Description:

When settting sameFormFieldsAsArray to true in the Application.cfc the value in the form scope cause an error when used with array member functions and when passed in to some array functions.

Steps to Reproduce:

    <cfset = "fields-as-fake-array-" & hash(getCurrentTemplatePath()) />
    <cfset this.sameFormFieldsAsArray = true />

<cfif form.keyExists("items") && isArray(form.items)>
    <cfset form.items.append(4) />
    <cfset arrayAppend(form.items, 4) />

<form method="POST">
    <input name="items" value="1">
    <input name="items" value="2">
    <input name="items" value="3">
    <button type="submit">Submit</button>

Actual Result:

Calling append on the array field throws an exception.

Expected Result:

Arrays resulting from sameFormFieldsAsArray should be real arrays and not array like objects. All methods and array functions should work without exceptions.

Any Workarounds:

<cfset form.items = arraySlice(form.items) />