Vague error: "No associative arrays allowed multiple=true"

32 views
Skip to first unread message

Patrick Nelson

unread,
Apr 23, 2015, 6:41:45 PM4/23/15
to silverst...@googlegroups.com
At first glance, would any of you know what this means?

No associative arrays allowed multiple=true

I do now, but if you haven't seen this before it may be a bit confusing (see actual code here). Basically, all you see is that line above with a stack trace. It turns out that this is a very logical error validation, but the message could be improved, in my opinion. 

Basically: When passing an array of current values to a ListboxField() (when you set it up to allow multiple values), it's checking to make sure you don't accidentally give it an associative array. There's one key word missing from that error message: "values". I'd suggest maybe changing this error to something a bit more like:

No associative arrays are allowed as values (when multiple=true).

That should make it easier to figure out what on earth just happened. It was confusing because I didn't receive the error until after saving my form, so it seemed fairly random.

I've already submitted like3 PR's in the past few days so I'm not sure I want to annoy you guys with another one if it's not worth it :)

Stevie Mayhew

unread,
Apr 23, 2015, 8:18:40 PM4/23/15
to silverst...@googlegroups.com
I think any improvement is great - PR away. I often miss things like this because of being so used to the system and how it works.

Patrick Nelson

unread,
Apr 23, 2015, 8:44:20 PM4/23/15
to silverst...@googlegroups.com
Ok no problem. So do you think this should go against 3 or 3.1? It's minor but also not necessarily a bug fix. 

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Stevie Mayhew

unread,
Apr 24, 2015, 12:02:31 AM4/24/15
to silverst...@googlegroups.com
I think that any documentation changes which improves the situation should be viewed as a bug fix rather than a minor patch. 

Someone will back me up I'm sure.

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Apr 24, 2015, 5:44:31 AM4/24/15
to silverstripe-dev
definitely a bug-fix of sorts... I'd put something along the lines of

Listboxes allowing multiple values can not be passed an associative array as preset values. ​

Patrick Nelson

unread,
Apr 25, 2015, 6:31:38 PM4/25/15
to silverst...@googlegroups.com
I just opted for this, see: https://github.com/silverstripe/silverstripe-framework/pull/4106

Associative arrays are not allowed as values (when multiple=true), only indexed arrays.

Anybody reading that should be able to end up realizing that we want a single set of values, not two, suggesting we are using the values from the array (as opposed to the keys) as the set of values which will be retained in the database, or associated with this field.


On Fri, Apr 24, 2015 at 5:44 AM, Nicolaas Thiemen Francken - Sunny Side Up <nfra...@gmail.com> wrote:
definitely a bug-fix of sorts... I'd put something along the lines of

Listboxes allowing multiple values can not be passed an associative array as preset values. ​

--
Reply all
Reply to author
Forward
0 new messages