Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable RelationManager list edit action #318

Merged

Conversation

mallardduck
Copy link
Contributor

This just adds a very simple method to complement the canCreate, canDelete, and canDetach methods. The benefit of this is a very easy way to make the relation manager only allow attach and detach actions.

@mallardduck mallardduck changed the title Add ability to disable RelationManager list edit action [WIP] Add ability to disable RelationManager list edit action Apr 5, 2021
@mallardduck mallardduck changed the title [WIP] Add ability to disable RelationManager list edit action Add ability to disable RelationManager list edit action Apr 5, 2021
@monoman81
Copy link

I made the same question earlier today on the filament discord server. What i have to do is this:

use Filament\Resources\RelationManager\ListRecords;
class ListMediaRecords extends ListRecords
{
    public function getRecordActions()
    {
        return [
        ];
    }
}

And in the RelationManager class override the $components static variable to tell filament that use my custom ListMediaRecords:

protected static $components = [
        'attach' => RelationManager\AttachRecord::class,
        'create' => CreateMediaRecord::class,
        'edit' => RelationManager\EditRecord::class,
        'list' => ListMediaRecords::class,
];

It works but seems to me a little bit of overkill if only need to remove the Edit action.

@mallardduck
Copy link
Contributor Author

@monoman81 - Thanks for providing that input, I think this helps to show how this PR could be a simpler alternative to that method. This method will also make the control of edit abilities match the others as mentioned in my OP.

@monoman81
Copy link

I agree with you. Regards.

@danharrin danharrin changed the base branch from main to develop April 11, 2021 22:41
@danharrin danharrin merged commit b09c849 into filamentphp:develop Apr 11, 2021
@danharrin
Copy link
Member

Thank you!

@danharrin danharrin added the enhancement New feature or request label Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants