I have an array filled with data like this:
$results[] = ['id' => $question->id, 'question' => $question->question, 'tag' => $tag->tag];
I want to pass that data into a Select element so that the value for each option is ID and the choice displayed is the question.
Based on the documentation I have tried this:
$select = new Select(
'question',
$results,
[
'class' => 'question-search',
'style' => "width: 100%",
'using' => [ $results['id'], $results['question']." ( ".$results['tag']." )"]
]
);
But that way it shows each $results entry as separated choices.
And by doing this:
foreach($results as $result)
$select->addOption([$result['id'], $result['question']." ( ".$result['tag']." )"]);
only the last record in the array is added. Please help, what am I missing?
Thanks