Hi there,

In my current plugin I need to show a dropdown with all the users that are part of specific group.

I noticed that RainLab\User\Models\User has the next scope scopeFilterByGroup but I don't understand how to pass a parameter using fields.yaml

    label: 'Admin'
    select: 'concat(name, '' '', surname)'
    scope: filterByGroup
    span: auto
    required: 1 
    type: relation
    tab: Information

I tried with

scope: filterByGroup(3)

but it is not working

As a temporary workaround I created a new scope method

public function scopeFilterByAdminGroup($query)
    return $this->scopeFilterByGroup($query, [3]);

But it is unnecesary and I'm not sure if I update the plugin, this part of my code will be removed.

Last updated



If the value 3 is hard coded then your solution is appropriate. The YAML cannot pass arguments to the scope functions, so this is the next best thing.

1-2 of 2