Skip to content

Commit

Permalink
Include labels for PHP instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
driusan committed Apr 26, 2024
1 parent 9e3e240 commit 35d8633
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions php/libraries/LorisFormDictionaryImpl.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,23 @@ trait LorisFormDictionaryImpl
// "1" array_keys turns it into an int and we want to
// ignore null/empty, so instead we just walk through
// the array and coerce things to a string.
$keys = [];
foreach (array_keys($element['options']) as $key) {
$keys = [];
$labels = [];
foreach ($element['options'] as $key => $label) {
if ($key === '' || $key === null) {
continue;
}

// Coerce it to a string
$keys[] = "$key";
$keys[] = "$key";
$labels[] = "$label";
}
if (array_key_exists('multiple', $element)) {
$card = new Cardinality(Cardinality::MANY);
}

$t = new \LORIS\Data\Types\Enumeration(...$keys);
$t = $t->withLabels(...$labels);
break;
case 'text':
$t = new \LORIS\Data\Types\StringType(255);
Expand Down

0 comments on commit 35d8633

Please sign in to comment.