Drop down menu 连接两个组件octoberCms后端

Drop down menu 连接两个组件octoberCms后端,drop-down-menu,components,backend,octobercms,Drop Down Menu,Components,Backend,Octobercms,找不到将两个组件连接在一起的方法。我在第一个组件中有一个表,需要从第二个组件获取列表,并将其显示为下拉列表。我有可能做到吗?谢谢 顺便说一句,忘了提一下。我需要在后端得到一个列表 您可以使用getOptions()方法: public function defineProperties() { return [ 'country' => [ 'title' => 'Country', 'type' =&

找不到将两个组件连接在一起的方法。我在第一个组件中有一个表,需要从第二个组件获取列表,并将其显示为下拉列表。我有可能做到吗?谢谢


顺便说一句,忘了提一下。我需要在后端得到一个列表

您可以使用
getOptions()
方法:

public function defineProperties()
{
    return [
        'country' => [
            'title'   => 'Country',
            'type'    => 'dropdown',
            'default' => 'us'
        ]
    ];
}

public function getCountryOptions()
{
    // here you can use DB or Model
    return ['us'=>'United states', 'ca'=>'Canada'];
}