Silverstripe admin: “Has one” dropdown converts to ordinary input field after import

前端 未结 1 1145
清歌不尽
清歌不尽 2021-01-19 19:22

I am having some problems with the admin of Silverstripe. I defined a database model (see class definitions below), and after I do a dev/build everything is looking as expec

相关标签:
1条回答
  • 2021-01-19 20:22

    You probably shouldn't only rely on the admin scaffolding, and use getCMSFields on your DataObjects to customize what happen in the CMS. In you case, a simple replace of the Troupe dropdown could work, adding this to your Package class:

    function getCMSFields()
    {
        $fields = parent::getCMSFields();
    
        $troupeList = Troupe::get()->map()->toArray();
        $troupeSelect = DropdownField::create('TroupeID', 'Troupe')->setSource($troupeList);
    
        $fields->replaceField('TroupeID', $troupeSelect);
    
        return $fields;
    }
    

    This is quite minimalist and a lot more could me customised.

    0 讨论(0)
提交回复
热议问题