I recently implemented a fix for open source Slatwall e-commerce platform to circumvent issues caused by Lucee trying to parse array bracket notation in form scope. Slatwall Patch for Lucee Form Scope Issue:
I was seeing some inconsistent behavior between ACF and Lucee with our logic in some cases. It really depends on how Lucee chooses to order the form scope variables and what new variables it litters it with.
The open source Slatwall e-commerce platform has internal logic that constructs the proper object tree using bracket and dot notation with variables from the url/form scopes (similar to what Lucee is trying to do).
Basically if you have form fields like this submitted in the request
But Lucee creates additional objects in the form scope and not in a way we find useful because of how it is naming keys still keeping the brackets. Take a look at the difference between the construction of the form scope between ACF and Lucee.
Or maybe add logic to Lucee to not process form fields that have dot notation into structs if they contain [n] since it appears to not be able to handle notation with both a mixture of brackets and dots at the same time. Or fully implement that functionality.
Let me explain first a little WHY things are as they are.
the setting “sameFormFieldsAsArray” is completely unrelated to this.
this influence if lucee combine multiple form/url with the same name to a string list or an array.
what is not the case here, you do not have to items in the form scope with the same name.
That Lucee creates a array in case a form/url field comes with “” at the end exists since Railo 1.0 and also is also completely unrelated to this. this only applies when name ends with “” what it does not in your case.
So the difference is that Lucee interprets the “.” in the name of a form/url variable.
Why if ACF does not?
Very simple acf does not but ACF interprets variable names.
so for example this works in ACF but not in Lucee
I think an application setting would be beneficial to disable form/url scope notation interpretation of literals so ACF form == Lucee form. Maybe setting name ‘disableScopeNotationInterpretation’?
I understand request.a.b.c != request['a.b.c'] in Lucee. That makes prefect sense. Lucee always treats ['a.b.c'] as a literal key and not evaluated or interpreted.
I do like how Lucee conveniently interprets ‘.’ in the scopes but for us its currently incomplete since it is limited that it can’t handle array notation. If it could take it another step and inspect the parsed key name to see if the key contains the array notation using a regex: \S+\[\d+\] (ie. somekey would match)
So form/url scope ?countries=US&countries=MX&countries=UK becomes
countries = ['US', 'MX', 'UK']
That preserves not only order but allows for consolidating complex types using the notation.