Reputation: 1952
I extended the user plugin to include extra form fields:
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'
],
]);
});
The new fields working fine, but I want to do some javascript functions before saving the form, I searched google and octobercms Javascrip API but no luck.
Please Advice,
Upvotes: 0
Views: 892
Reputation: 621
Add this to your Plugin.php file:
...
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) === 'RainLab\User\Controllers\Users') {
$controller->addJs('/your-custom-js/file.js');
}
});
}
}
....
}
Upvotes: 3