Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
If you want to extend a Settings of another plugin or backend section to add fields i.e. the ones that don't have an exclusive controller but rather are just a settings page, you need to extend the form widget associated with it. Now at first if you look at System\Controllers\Settings, the class responsible for rendering settings it may feel like a good idea to extend that and called extendFormFields from your Plugin boot but it wouldn't work since the Settings controller is a special controller that doesn't implement form behavior but directly loads a formwidget internally. So to extend it, you have to hook into it's Form's extension methods. As an example, let us extend the Maintainence Mode page from another plugin. In the Plugin.php boot method, include: ``` Event::listen('backend.form.extendFields', function ($widget) { if (!$widget->getController() instanceof \System\Controllers\Settings) { return; } // Only for the MaintenanceSetting model if (!$widget->model instanceof \Cms\Models\MaintenanceSetting) { return; } $widget->addFields([ 'disable_feature' => [ 'label' => 'Disable Feature?', 'type' => 'switch' ] ]); }); ```
References
Add additional online resources to your trick
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline