Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [SOLVED]Latest revision fails on Sort field

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 753 Views
  • NickJacobs
    Avatar
    Community Member
    144 Posts

    [SOLVED]Latest revision fails on Sort field Link to this post

    Hi, I've had a site running sweet with the DOM, and upgraded it to rev347 and now I get errors in the CMS (Undefined offset error). I've tracked it down to the Sort parameter...with anything in there I get the error....with no sort parameter specifed it works fine.

    code is:

    public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new DataObjectManager(
             $this, // Controller
             'Endangereds', // Source name
             'Endangered', // Source class
             array('Family' => 'Family', 'Genus' => 'Genus','Species' => 'Species','CommonName' => 'CommonName'), // Headings
             'getCMSFields_forPopup' // Detail fields function or FieldSet
             ,""// Filter clause
             ,"Genus"// Sort clause
             // Join clause
          );
          
          $f->addFieldToTab("Root.Content.EndangeredList", $manager);
          
          return $f;
       }

    data object is:

    class Endangered extends DataObject
    {
       static $db = array (
          'Family' => 'Text',      
          'Genus' => 'Text',
          'Hybrid' => 'Text',
          'Species' => 'Text',      
          'Infraspecific' => 'Text',
          'Cultivar' => 'Text',
          'CultivarGroup' => 'Text',
          'Synonym' => 'Text',
          'CommonName' => 'Text',
          'Continent' => 'Text',
          'GeoRegion' => 'Text',
          'Herbarium' => 'Boolean',
          'IUCNCode' => 'Text',
          'Fieldx1' => 'Text',
          'Var' => 'Text'
       );
       
       static $has_one = array (
          'EndangeredPage' => 'EndangeredPage',
          'PlantImage' => 'Image'
       );
       
       static $searchable_fields = array(
       'Family','Genus','Species','CommonName'
       );
       
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             
             new TextField('Family'),
             new TextField('Fieldx1'),
             new TextField('Genus'),
             new TextField('Hybrid'),
             new TextField('Species'),
             new TextField('Var'),
             new TextField('Infraspecific'),
             new TextField('Cultivar'),
             new TextField('CultivarGroup'),
             new TextField('Synonym'),
             new TextField('CommonName'),
             new TextField('Continent'),
             new TextField('GeoRegion'),
             new CheckboxField('Herbarium','In herbarium?'),
             new TextField('IUCNCode'),
                      
             new ImageField("PlantImage", "Plant Image")
          );
       }
    }

    If I remove Genus from the sort it works fine.....
    running ss2.3.5 (stable) and DOM,SWFupload, Image_Gallery rev347

    any ideas??

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED]Latest revision fails on Sort field Link to this post

    Hi, Nick,

    Could you paste the exact error, please?

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED]Latest revision fails on Sort field Link to this post

    Oh, you might want to try "Genus ASC" for your sort clause. Let me know if that fixes anything.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: [SOLVED]Latest revision fails on Sort field Link to this post

    Ha, yes thats cracked it! Is this a recent change (explicit sort direction required)?

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED]Latest revision fails on Sort field Link to this post

    Yeah, stupid me. I'll be checking in a patch momentarily.

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