扩展Octobercms中的用户插件后端表单



我扩展了用户插件以包括额外的表单字段:

UsersController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'mobile' => [
'label' => 'Mobile',
'type'  => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
'phone' => [
'label' => 'Phone',
'type'  => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
]);
});

新的字段工作正常,但我想在保存表单之前做一些javascript函数,我搜索了谷歌和octopercms Javascrip API,但运气不佳。

,请注意

将其添加到Plugin.php文件中:

...
use App;
use Event;
class Plugin extends PluginBase
{
public function boot()
{
if (App::runningInBackend()) {
Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
if (get_class($controller) === 'RainLabUserControllersUsers') {
$controller->addJs('/your-custom-js/file.js');
}
});
}
}
....
}

最新更新