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

$summary_fields does not display SS_Datetime fields?


Go to End


7 Posts   1177 Views

Avatar
_Vince

Community Member, 165 Posts

12 September 2011 at 9:02pm

Hi, I have a table of dates

class TournamentDate extends DataObject{

static $db = array(
"TournamentDateTime" => "SS_Datetime"
);

}

if I view the data in the ModelAdmin, the summary fields consist of the record ID.

If I add

static $summary_fields = array(
"TournamentDateTime" => "Tournament Date"
);

the ModelAdmin displays nothing. It just says "No items found", even though looking at the tables, I can see there's two records.

Why?

And how do I get around this?

Avatar
swaiba

Forum Moderator, 1899 Posts

13 September 2011 at 12:50am

"casting" could be used to work around this, but I do not know why you have no results at the moment

Avatar
_Vince

Community Member, 165 Posts

13 September 2011 at 1:09am

Thanks for the reply.

Casting sounds a bit involved. Would I have to overload the SS_Datetime class or the ModelAdmin?

I suspect the problem is that the SS_Datetime is a composite field and that's what complicates matters? But really, I've no idea.

Avatar
swaiba

Forum Moderator, 1899 Posts

13 September 2011 at 1:20am

casting isn't too invlolved - but yes it's not coming right out of the box
in my view it's a better option that modifying anything in "cms" or "sahppire"

Avatar
martimiz

Forum Moderator, 1391 Posts

13 September 2011 at 4:33am

You're on the right track - the searchbox on the left stumbles on the composite field. Try the following to replace the composite field by a textfield - you can still search on parts of the datetime...

    	static $searchable_fields = array(
		'TournamentDateTime' =>  array(
			'field' => 'TextField'
	));

Avatar
swaiba

Forum Moderator, 1899 Posts

13 September 2011 at 4:42am

ah was that it?

believe it or not I've never used the SS_DateTime - everything is with a Date or a Time in my systems.

you also have the option to manipulate the fields from within...

	public function scaffoldSearchFields() {
	   $fields = parent::scaffoldSearchFields();

		return $fields;
	}

And if you want to go to town...
http://www.leftandmain.com/silverstripe-tutorials/2011/03/15/taming-the-beast-remodeling-modeladmin-part-2/

Avatar
martimiz

Forum Moderator, 1391 Posts

14 September 2011 at 12:40am

@swaiba: neither had I - and now I'm not going to, I think...

Thanks for the link, I had done some heavy remodelling before, but it's not a bad idea to follow a similar track to what others do... :-)