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,
When I try to extend a form in my Plugin.php with a repeater widget using addFields() or addTabFields() this includes all fields of the parent form. What is happening here?
public function boot()
{
Event::listen('backend.form.extendFields', function($widget) {
// Only for the User controller
if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
return;
}
// Only for the User model
if (!$widget->model instanceof \RainLab\User\Models\User) {
return;
}
// This includes the fields from the parent form instead instead...
$widget->addTabFields([
'custom' => [
'tab' => 'Custom Fields',
'prompt' => 'Add',
'type' => 'repeater',
'groups' => '$/briddle/crm/config/repeater_fields_user.yaml'
]
]);
});
}
Last updated
Ok,
I was also extending the form with some other fields. I can hide these by wrapping them inside:
if($widget->isNested === false) {
// Only on the main form please...
}
But, the fields from the User Plus plugin still get added to my repeater
Last updated
Ok,
So I am also using the User Plus plugin.
In Plugin.php of this plugin I had to change:
protected function extendUsersController()
{
UsersController::extendFormFields(function($widget) {
// Prevent extending of related form instead of the intended User form
if (!$widget->model instanceof UserModel) {
return;
}
$configFile = plugins_path('rainlab/userplus/config/profile_fields.yaml');
$config = Yaml::parse(File::get($configFile));
$widget->addTabFields($config);
});
}
To:
protected function extendUsersController()
{
UsersController::extendFormFields(function($widget) {
// Prevent extending of related form instead of the intended User form
if (!$widget->model instanceof UserModel) {
return;
}
$configFile = plugins_path('rainlab/userplus/config/profile_fields.yaml');
$config = Yaml::parse(File::get($configFile));
if($widget->isNested === false)
{
$widget->addTabFields($config);
}
});
}
I have also notified RainLab of this issue as this patch it is overwritten when you update the User Plus plugin :)
https://github.com/rainlab/userplus-plugin/issues/30
Last updated
1-4 of 4