Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Remove Link Existing but keep Add for grid field.


Go to End


4 Posts   4463 Views

Avatar
Dig

Community Member, 33 Posts

22 December 2014 at 1:38pm

As in the subject really, this is in a Model Admin and I'm doing some tidying up of the fields and I would like to be able to get the existing GridField for my has many relationship and let users either add new ones or remove existing ones, but Link Existing is confusing and not a suitable use case for this editor. How do I remove it?

Cheers,
Nick

Avatar
camfindlay

Forum Moderator, 267 Posts

23 December 2014 at 8:25am

Edited: 23/12/2014 8:25am

I think GridFIeld shows a Link Existing dependant on how you have modelled the data. If the dataobject can exist when not connected to something (for example tags) then GridField will add that UI to reconnect objects.

I think you can also extend and override ModelAdmin's forms, there is mention of some extension hooks you can use to do this at http://beta.docs.silverstripe.org/en/developer_guides/customising_the_admin_interface/how_tos/extending_an_existing_modeladmin/

Avatar
JackOconnor

Community Member, 3 Posts

25 February 2016 at 4:34am

Edited: 25/02/2016 4:38am

The two components on the grid field CAN be removed separately. If you wish to remove the add button alone you would get the grid field config and call the following:

$config->removeComponentsByType('GridFieldAddNewButton');
Otherwise If you want to remove the link existing input you would retrieve the grid field config and then call the following:
$config->removeComponentsByType('GridFieldAddExistingAutocompleter');

Avatar
shellbackpacific

Community Member, 2 Posts

28 October 2016 at 6:19am

JackOconnor Stole my profile photo