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.

All other Modules /

Discuss all other Modules here.

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

ModelAdmin Issues

Go to End

4 Posts   1241 Views


Community Member, 11 Posts

20 March 2011 at 1:36pm

Edited: 20/03/2011 5:06pm

Ok, I've been learning Silverstripe and I've gone though the first tutorials. I've been using the book and the forums/documentation etc to learn everything, and so far so good. However I'm having some issues attempting to work with the ModelAdmin class for the first time, and I haven't really done much.

I've created a quotes system that shows a random quote in the side bar on every page. I have a database of quotes and the sidebar module is working correctly. Now I want to make an admin tool to allow admin to manage the quotes, edit and add new ones. I've created an admin area with the following code:

class QuoteAdmin extends ModelAdmin {
	static $managed_models = array(
	static $searchable_fields = array(
	static $url_segment = 'quotes';
	static $menu_title = 'Quotes';
	static $model_importers = array(
		'Quote' => 'QuoteCsvBulkLoader',


I have two issues with this that I cannot seem to resolve.

1: None of the search fields show. At all. Only one field shows called '#ID' (It is a drop down box that contains an entry for every quote in the db.

2: None of the data fields show in the search results. Only #ID for each quote. However clicking the results shows the quotes and allows them to be edited.

What am I missing? I'm assuming the two issues are related but I can't track down the answer. And yes, I know I'm a newb. ;)


Forum Moderator, 5523 Posts

20 March 2011 at 5:48pm

$searchable_fields should be attached to your model class (Quote), not the admin class.


Community Member, 11 Posts

21 March 2011 at 1:21am

Thanks for your reply.

Thank fixed the search fields problem. :) However all the search results are still the same. The only field that shows in results is 'ID'. Reading documentation I can see how to customize the field names for each column in the results with $summary_fields. However reading the docs gives me the idea that this should only be needed if you want the fields to display something other than the column name, and otherwise should not be required.

Is that correct?


Community Member, 11 Posts

21 March 2011 at 5:10am

I feel like a bit of a dolt now, after re-reading the doc file for 'DataObject'. I was lead to believe by reading ModelAdmin that I did not need to define $summary_fields, I realize now that it is required. Sorry, I should have rtfm a little more closely before asking.