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
To be more compatible to ACF we decided do read the “.” as struct seprator when parsing url or form scope instead.
it turned out to be the best solution for most users.
But for cases like yours we added the function StructKeyTranslate(form,true,true) that flattens the key in a struct. so you get what you need.
Sure we can discuss a setting to disable that behaviour, should not be a big deal.
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[2] would match)
So form/url scope ?countries[1]=US&countries[2]=MX&countries[3]=UK becomes
countries = ['US', 'MX', 'UK']
That preserves not only order but allows for consolidating complex types using the notation.
Was there ever a setting added to Lucee to disable form scopes bracket notation parsing? Lucee uses a different form field naming convention than other languages, which has caused confusion.
Specifically, similar to OP, a form field named group[1].id should be interpreted as an array of structs, not a struct named group[1]
I know it would introduce a breaking change to have Lucee change the behavior, but being able to disable it, as OP suggested would be a welcome addition. for Lucee 5 and 6