public function getCMSFields($params = array()) { $fields = new FieldList(DropdownField::create("ProductID", "Product", Product::get()->map()->toArray())->setHasEmptyDefault(true)); $menu = $this->Menu(); if (!$menu->exists()) { $menu = isset($params["MenuID"]) ? Menu::get()->byID((int) $params["MenuID"]) : null; } if ($menu && $menu->exists()) { $fields->push(DropdownField::create("GroupID", 'Menu Group', MenuGroup::get()->filter("ParentID", $this->MenuID)->map('ID', 'Title')->toArray())->setHasEmptyDefault(true)); } if ($this->Product()->exists() && !$this->Product()->canPurchase()) { $fields->push(LiteralField::create("purchasenote", "<p class=\"message warning\">This product can't be purchased, so it won't show up in menus</p>")); } return $fields; }