Thanks Lukas. Now I’m testing with a hard coded, multidimensional array of menu items as the return from the options
method. One issue I’m having is it won’t save. I keep getting the “Please fill in all fields correctly” warning. If I return a one-dimensional array of pages and their titles from the options
method, it saves just fine.
I’ve narrowed it down to some checking feature that compares the array keys. It will save a checkbox selection if the secondary array key is the same as the primary array key. In the following example, menus/fries
will not save, but if I set the fries key to menus/starters
, it will save.
// site/fields/menuselect/menuselect.php
class MenuselectField extends CheckboxesField {
public function options() {
$menu_categories = array (
'menus/starters' => array(
// 'menus/fries' => 'Fries ', // will NOT save
'menus/starters' => 'Fries ', // will save
'menus/chips-dip' => 'Chips & Dip',
...
),
...
);
return $menu_categories;
}
public function content() {
...
foreach($this->options() as $menu_page => $menu_items) {
$html .= "<h1>$menu_page</h1>";
foreach($menu_items as $menu_item => $value) {
$html .= '<li class="input-list-item field-grid-item' . $width . '">';
$html .= $this->item($menu_item, $value);
$html .= '</li>';
}
}
...
}