Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » $summary_fields does not display SS_Datetime fields?

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

Page: 1
Go to End
Author Topic: 653 Views
  • _Vince
    Avatar
    Community Member
    161 Posts

    $summary_fields does not display SS_Datetime fields? Link to this post

    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?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

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

  • _Vince
    Avatar
    Community Member
    161 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

    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.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

    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"

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

    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'
       ));

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

    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/

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: $summary_fields does not display SS_Datetime fields? Link to this post

    @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...

    653 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.