anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00311
[Branch ~uws/anewt/anewt.uws] Rev 1817: [form] Fix string casts for multiple select choice controls
------------------------------------------------------------
revno: 1817
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Thu 2011-03-17 15:12:10 +0100
message:
[form] Fix string casts for multiple select choice controls
The value for AnewtFormControlChoice with the 'multiple'
flag set is an array, not a string. The previous change
casted all values to string, while for multiple select
choice controls this should be done for each value instead.
modified:
form/controls/choice.lib.php
--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws
Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'form/controls/choice.lib.php'
--- form/controls/choice.lib.php 2011-03-17 14:03:28 +0000
+++ form/controls/choice.lib.php 2011-03-17 14:12:10 +0000
@@ -211,7 +211,21 @@
* integer 0" comparison issues when filling from e.g. database records
* containing real integer values. */
$name = $this->get('name');
- $value = (string) array_get_default($values, $name, null);
+
+ if ($this->multiple)
+ {
+ $value = array();
+
+ $raw_values = array_get_default($values, $name);
+ if ($raw_values)
+ foreach ($raw_values as $raw_value)
+ $value[] = (string) $raw_value;
+ }
+ else
+ {
+ $value = (string) array_get_default($values, $name, null);
+ }
+
parent::fill(array($name => $value));
/* Filling succeeds if... */