Hi guys,
I’m fetching database data and adding it to a select field:
Database data
- Table: accommodatie_status
- Column 1: id (int)
- Column 2: status_nl (text)
Page model
public function getZoekertjesStatus():array {
$statuses = Db::select("accommodatie_status", ["id", "status_nl"]);
$array = [];
if( !$statuses ) {
return $array;
}
foreach( $statuses as $item ) {
$array[$item->id()] = $item->status_nl();
}
return $array;
}
Page blueprint
accommodatie_status_id:
label: Status
type: select
options:
type: query
query: site.find('zoekertjes').getZoekertjesStatus
value: '{{ arrayItem.key }}'
text: "{{ arrayItem.value }}"
When changing the select field value, the database gets updated correctly. However, the select field doesn’t stay selected on the current value, it alows shows the empty value:
When I change the select field to a text field, the value is getting represented correctly:
I would like the select field to keep the current database value selected.
Is there something I’m missing here? Thanks!