Backend setting is not showing anything

Hi,

I try to add a backend setting to my plugin. For this, I created a model called Setting. I changed the model so it uses the base class System\Models\SettingModel. I also set the variables $settingsCode and $settingFields.

use System\Models\SettingModel;

class Setting extends SettingModel
{
    
    public $settingsCode = 'myname_myplugin_settings';

    public $settingFields = 'fields.yaml';

    // ...
}

On the settings page, the user should be able to enter some API Token, so I adjusted fields.yaml like this:

# ===================================
#  Form Field Definitions
# ===================================

fields:
    id:
        label: ID
        disabled: true

    api_token:
        label: "API Token"
        disabled: false
        default: ""

And I also adjusted columns.yaml:

# ===================================
#  List Column Definitions
# ===================================

columns:
    id:
        label: ID
        searchable: true

    api_token:
        label: "API Token"
        type: text
        searchable: true

I also created a SettingsController with php artisan create:controller myname.myplugin SettingsController. The only thing I changed there was to add $settingsItemCode and set it to the value myname_myplugin_settings .

But when I got to the backend settings page of my plugin, I see no form where I can enter the API token. What I am missing here?

Don’t forget to create the view file with your controller. Without one, it would indeed show an empty page.