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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Single record in ModelAdmin

Go to End

5 Posts   848 Views


Community Member, 14 Posts

3 September 2013 at 6:37pm

Hey guys. I've been using ModelAdmin for most of my modules, and it have worked out great until now since all of my modules worked with lists/multiple records.

Now I kind of need to let admins set some settings backend, and therefor I don't need a list/multiple records. I just need a single record. I want to do exactly the same as the "Settings" tab backend in Silverstripe looks like.

How can I do this? I was wondering if there was some other approach than using ModelAdmin, or if I have to modify it to get what I want.

Thanks guys.


Forum Moderator, 1899 Posts

4 September 2013 at 1:17am

Hi haugen,

Where I've done this in the past I've restricted permissions so the the record cannot be created or deleted.
Also reduce the search for (so people don't think of it like other records).
Using requireDefaultRecords to create one on dev/build if it doesn't exist.

My model admin auto searches so the only issue it that they still need to click on the record to edit it.

Hope this helps


Community Member, 14 Posts

4 September 2013 at 10:39pm

Thanks, this works.

Only thing is that

function canCreate() {
return false;

Didn't work as expected. They're still able to add new records. canDelete worked as expected.


Forum Moderator, 1899 Posts

4 September 2013 at 11:01pm

how about...

	function canAdd()		{return false;}


Community Member, 14 Posts

9 September 2013 at 8:27pm

Excellent. Amazing I didn't even try it before asking ;)

Thanks alot for quick replies, pretty awesome community.