Hello,
I am making a custom setting form for a plugin in the backend. I have render the form in controller index.htm and saving the form onSave event. however now i am lost how to populate the form entries from config/database table.
the database table is my_clients_setting.
the columns are:
id (PK),
status(booloean => switch)
key(identifier => string)
value(value of the form => string)
fields:
status:
label: ''
span: full
on: Disable
off: Enable
type: switch
key:
label: Key
span: auto
disabled: 1
type: text
value: 'Test'
value:
label: Value
span: auto
type: text
following is my controller
public $implement = [
//'Backend\Behaviors\ListController',
'Backend\Behaviors\FormController' ];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('My.Clients', 'main-menu-clients', 'side-menu-client-settings');
}
public function index() {
$this -> initForm($this);
$this -> pageTitle = 'My Clients Settings';
}
public function onSave(){
$saveSettings = new \My\Clients\Models\MyClientsSettings();
$saveSettings->status = true;
$saveSettings->key = 'key';
$saveSettings->value = 'value';
$saveSettings->save();
}
i saw this article which is what i want to have but it is not very clear that how one can implement this in a custom controller/form
https://docs.octobercms.com/2.x/plugin/settings.html#settings-link-registration
Thank you in advance