This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi!
I'm writing a plugin that extends the Ranlab User plugin, and I'm having problems with how to extend the backend. First, some info about my plugin:
I have a model called Organization with the following relation:
class Organization extends Model
{
// ...
public $hasMany = [
'users' => ['RainLab\User\Models\User'],
];
// ...
}
In Plugin.php:
public function boot()
{
UserModel::extend(function($model) {
// The user is an ORGANIZATION, and has organization info:
$model->hasOne['orginfo'] = ['TF\User\Models\Organization'];
// The user is a MEMBER of an organization:
$model->belongsTo['organization'] = ['TF\User\Models\Organization'];
});
UsersController::extendFormFields(function($form, $model, $context) {
if (!$model instanceof UserModel)
return;
if (!$model->exists)
return;
$user = $model; // For clarity / readabillity below.
if ($user->orginfo) {
//
// User is an ORGANIZATION:
//
$form->addTabFields([
'orginfo[contact_name]' => [
'label' => 'Contact First Name',
'tab' => 'Contact Info',
'span' => 'auto',
],
// How do I render a list of organization members (users) in a new
// "Members" tab? I would prefer to use the built in backend list
// functionality of October CMS.
]);
}
// ...
}
}
How do I make October CMS display a list of users -- that are members of (belong to) the organization user currently being viewed -- under a new "Members" tab in the backend?
Feel free to ask for more information about my plugin / code.
Many thanks in advance for any help you can provide.
/Petrus
Last updated
I understand from reading https://octobercms.com/docs/backend/widgets and http://www.sitepoint.com/build-octobercms-widget-plugin/ that I can create a widget that displays the list of users that are members of the organization user that is currently being viewed. But I'm unsure whether I should use a "generic widget" or a "form widget" for this. Also, if I use a generic widget, how do I call that from the ->addTabFields([...]); so it is rendered in a new tab called "Members"?
1-2 of 2