Happy Friday,
could someone give me a hint how to access a custom list?
I want to have 3 dropdowns in the header to share some specific information. I can make a regular dropdown with items provided in the code. But I would like to have access to a custom list I created earlier so I don't have to change the hardcoded items all the time.
I am a little bit confused how to do it since there is the list array and the items array I assume I have to bring them somehow together.
Don't laught but that was my attempt:
<?php
// Load the custom list options
$customListOptions = array();
$customList = CustomList::objects()->filter(array('name' => 'Test'))->one();
if ($customList) {
$customListOptions = $customList->getOptions();
}
// Use custom list
foreach ($customListOptions as $option) {
echo $option . '<br>';
}
?>
and this is what I have and what works, but the Items are hardcoded which sucks
<select name="Test" id="Test">
<option value="item1">Item1</option>
<option value="item2">Item2</option>
<option value="item3">Item3</option>
<option value="item4">Item4</option>
</select>
I would appreciate some help
Best regards
waczny