Hi! I’m trying to render a model settings form in the controller’s index.php file, but I can’t figure it out.
Can anyone help me with this?
Fields from Settings page in your custom model?
Or you made Settings model with fields and settings only displaying in Settings page?
I have defined the settings:
public function registerSettings()
{
return [
'news' => [
'label' => 'Settings',
'category' => 'Other',
'icon' => 'icon-cog',
'class' => \Test\News\Models\News::class,
'order' => 500,
]
];
}
They are displayed on the “Settings” page:
But I need to display them on a custom page:
Hi @apinard,
For a testing purposes, I downloaded the October Test Plugin. What I’m trying to achieve is to move Playground Settings from default settings page to custom Playground page.
Now it looks like this:
What I’m trying to achieve:
Plugins.php file contains:
public function registerSettings()
{
return [
'test' => [
'label' => 'Playground Settings',
'description' => 'Settings for the test plugin',
'category' => SettingsManager::CATEGORY_MISC,
'icon' => 'icon-child',
'class' => \October\Test\Models\Setting::class,
'order' => 500,
'keywords' => 'settings october test',
'permissions' => ['october.test.manage_settings']
]
];
}
public function registerNavigation()
{
return [
'test' => [
'label' => 'Playground',
'url' => Backend::url('october/test/people'),
'icon' => 'icon-child',
'order' => 198,
'permissions' => ['october.test.access_plugin'],
'sideMenu' => [
// ...
'setting' => [
'label' => 'Playground Settings',
'icon' => 'icon-child',
'url' => Backend::url('october/test/setting'),
],
],
],
];
}
I created the controllers/Setting.php file:
<?php namespace October\Test\Controllers;
use BackendMenu;
use Backend\Classes\Controller;
/**
* Setting Back-end Controller
*/
class Setting extends Controller
{
public function __construct()
{
parent::__construct();
BackendMenu::setContext('October.Test', 'test', 'setting');
}
}
I assume I need to add something like this to the controller:
public function index()
{
$this->asExtension('FormController')->create();
}
And <?= $this->formRender() ?>
to index.php file, but something is missing.
After some time of searching I found the solution to my problem: