Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
viames committed Sep 25, 2024
1 parent f12d3de commit 007140c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1374,15 +1374,18 @@ public function setListByObjectArray(array $list, string $propertyValue, string
*/
public function setOptions(array $list, ?string $propertyValue=NULL, ?string $propertyText=NULL, ?array $propertyAttributes = NULL): FormControlSelect {

// if associative array, convert it to object list
if (is_array($list) and array_keys($list) !== range(0, count($list) - 1)) {
$allowedValues = ['string','integer','double'];

// check if associative array
if (is_array($list) and in_array(gettype(reset($list)), $allowedValues)) {

$objectList = [];

// convert associative array to a stdClass array
foreach ($list as $value=>$text) {
$object = new \stdClass();
$object->value = $value;
$object->text = $text;
$object->text = (string)$text;
$objectList[] = $object;
}

Expand Down

0 comments on commit 007140c

Please sign in to comment.