From bfd8b6663afd747e9b2111cd6f4f27e059aaed73 Mon Sep 17 00:00:00 2001 From: Patrick Nelson Date: Sat, 25 Apr 2015 18:26:11 -0400 Subject: [PATCH] FIX for #4104, minor revision of error messages in ListboxField (more intuitive). --- forms/ListboxField.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forms/ListboxField.php b/forms/ListboxField.php index 9c672e045..b793a7b75 100644 --- a/forms/ListboxField.php +++ b/forms/ListboxField.php @@ -215,13 +215,14 @@ class ListboxField extends DropdownField { if($val) { if(!$this->multiple && is_array($val)) { - throw new InvalidArgumentException('No array values allowed with multiple=false'); + throw new InvalidArgumentException('Array values are not allowed (when multiple=false).'); } if($this->multiple) { $parts = (is_array($val)) ? $val : preg_split("/ *, */", trim($val)); if(ArrayLib::is_associative($parts)) { - throw new InvalidArgumentException('No associative arrays allowed multiple=true'); + // This is due to the possibility of accidentally passing an array of values (as keys) and titles (as values) when only the keys were intended to be saved. + throw new InvalidArgumentException('Associative arrays are not allowed as values (when multiple=true), only indexed arrays.'); } // Doesn't check against unknown values in order to allow for less rigid data handling.