Removing a relation in a GridField

Showing 1-2 of 2 messages
Removing a relation in a GridField baba-papa 10/5/12 6:53 AM
The GridFieldAddExistingAutocompleter helps making relation between objects. I would expect the scaffolded the GridField to offer a button to remove relations but there is only a button to delete the whole object. Is there a solution for this issue?

Further I suggest that objects may only be deleted in their own ModelAdmin for security reasons.
Re: Removing a relation in a GridField Ingo Schommer 10/5/12 7:42 AM
Hello Roland!

On Friday, October 5, 2012 3:53:42 PM UTC+2, baba-papa wrote:
The GridFieldAddExistingAutocompleter helps making relation between objects. I would expect the scaffolded the GridField to offer a button to remove relations but there is only a button to delete the whole object. Is there a solution for this issue?
To quote the PHPDoc for the class ;)
Often used alongside {@link GridFieldRemoveButton} for detaching existing records from a relationship.
Incidentally, that's the wrong class name, should be GridFieldDeleteAction - which I've just fixed. 
  

Further I suggest that objects may only be deleted in their own ModelAdmin for security reasons.
That might be useful in your context, but others will want to provide full edit/delete
capabilities in different "views", one of which can be a ModelAdmin.
There's no concept of "an object's own ModelAdmin" in core,
you can have the same object editable through GridFields in other places,
even through multiple ModelAdmins. I would suggest you simply don't add the 
GridFieldDeleteAction component to views where you want to avoid deletion,
and leave global permission management to canDelete().

Ingo