This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I'm trying to extend/override the listInjectRowClass and listOverrideColumnValue methods from
my plugin which extends the User plugin.
I've tried this in my Plugin.php file:
public function boot()
{
...
Event::listen('backend.list.listInjectRowClass', function($record) {
return 'safe disabled nolink';
});
...
}
but it doesn't work.
Is such extending possible ?
For those who are interested here's the solution:
public function boot()
{
...
\RainLab\User\Controllers\Users::extend( function($controller) {
Event::listen('backend.list.injectRowClass', function ($listWidget, $record, &$value) {
$value .= 'safe disabled nolink';
});
Event::listen('backend.list.overrideColumnValueRaw', function ($listWidget, $record, $column, &$value) {
$value .= '-modified';
});
});
...
}
Hope it helps.
There is no need to extend the controller here, those are global events... it didn't work in your previous example because you had the wrong event name (backend.list.listInjectRowClass
)
just this will work:
public function boot()
{
Event::listen('backend.list.injectRowClass', function ($listWidget, $record, &$value) {
$value .= 'safe disabled nolink';
});
...
}
There is no need to extend the controller here
Actually it does or the $value will apply to the list of all the plugins.
Last updated
The event will trigger no matter what the list is. In order to handle the event for the right controller/model you need to check this within the handler.
There were 2 errors in your code snippet. Here's the corrected version:
if (!$listWidget->getController() instanceof \RainLab\User\Controllers\Users) {
return;
}
lucas.sanner54070 said:
if (!$listWidget->getController() instanceof \RainLab\User\Controllers\Users) {
return; }
Thanks! This works for me.
Last updated
1-10 of 10