This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hey everyone! I have a plugin which extends the User model with relations. I want to go further by extending its forms. I've managed to add a field with the type 'relation', which gives me checkboxes. I'd like to have a RelationController-style box in the form instead. I figure I'd have to implement RelationController behavior on the UserController, but how do I extend it this way from my own plugin?? I'm using Rainlab\User
Thanks.
Last updated
Just as a note to what I found as I have been doing some extending of the Rainlab\User plugin. Hopefully this will help someone out.
Example of extending the user plugin:
Directory Layout:
plugins
- ashleighsims
-- myplugin
--- extensions
---- user
----- UserExtentions.php
----- config_relation.yaml
----- config.yaml
----- _my_field_partial.htm
Extending the relation config...
...
use RainLab\User\Controllers\Users;
...
Users::extend(function ($controller) {
// If the controller doesn't alredy implement the relation config add this...
$controller->implement[] = 'Backend.Behaviors.RelationController';
// See above directory layout to understand this better
$controller->relationConfig = __DIR__ . '/config_relation.yaml';
});
Extending the fields...
...
use RainLab\User\Controllers\Users;
...
Users::extendFormFields(function ($widget) {
$configFile = __DIR__ . '/fields.yaml';
$config = Yaml::parse(File::get($configFile));
$widget->addTabFields($config);
});
1-3 of 3