Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » From ManyManyComplexTableField to ManyManyDataObjectManager

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: 1390 Views
  • BlueO
    Avatar
    Community Member
    52 Posts

    From ManyManyComplexTableField to ManyManyDataObjectManager Link to this post

    Hi there,

    This is my first foray into the dataobjectmanager and I'm having a little trouble. I have a working $many_many $belongs_many_many relationship going and I have a ManyManyComplexTableField to manage the relationship.
    It works well but I'm keen to get the filter/search features of the DOM.

    So started out replacing this:

    function getCMSFields() {
        $fields = parent::getCMSFields();
       
       $tablefield = new ManyManyComplexTableField (
    $this,
    'Bills',
    'Bill',
    array(
    'Type' => 'Type',
        'Total' => 'Total',
        'Date' => 'Date',
    ),
    'getCMSFields_forPopup'
    );
    $tablefield->setAddTitle( 'A Bill' );

    $fields->addFieldToTab( 'Root.Content.Bills', $tablefield );

       
       return $fields;
    }

    with this:

    function getCMSFields() {
        $fields = parent::getCMSFields();
       
       $tablefield = new ManyManyDataObjectManager (
    $this,
    'Bills',
    'Bill',
    array(
    'Type' => 'Type',
        'Total' => 'Total',
        'Date' => 'Date',
    ),
    'getCMSFields_forPopup'
    );
    $tablefield->setAddTitle( 'A Bill' );

    $fields->addFieldToTab( 'Root.Content.Bills', $tablefield );

       
       return $fields;
    }

    but I get an error when accessing the cms that I think is about a missing 'IF' argument but can't quite tell:

    [User Error] Couldn't run query: SELECT "Bill"."ClassName", "Bill"."Created", "Bill"."LastEdited", "Bill"."Total", "Bill"."Type", "Bill"."Date", "Bill"."ID", CASE WHEN "Bill"."ClassName" IS NOT NULL THEN "Bill"."ClassName" ELSE 'Bill' END AS "RecordClassName", IF(`Flatmate_Bills`.`FlatmateID` IS NULL, '0', '1') AS Checked FROM "Bill" LEFT JOIN `Flatmate_Bills` ON (`Bill`.`ID` = `BillID` AND `Flatmate_Bills`.`FlatmateID` = '5') GROUP BY "Bill"."ClassName", "Bill"."Created", "Bill"."LastEdited", "Bill"."Total", "Bill"."Type", "Bill"."Date", "Bill"."ID", CASE WHEN "Bill"."ClassName" IS NOT NULL THEN "Bill"."ClassName" ELSE 'Bill' END LIMIT 0, 10 | no such function: IF

    It would be great to get a little insight as to where i'm going wrong!

    thanks

    Bernie

  • UncleCheese
    Avatar
    4085 Posts

    Re: From ManyManyComplexTableField to ManyManyDataObjectManager Link to this post

    You're using MySQL?

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • BlueO
    Avatar
    Community Member
    52 Posts

    Re: From ManyManyComplexTableField to ManyManyDataObjectManager Link to this post

    Oh man, yeap I was using sqlite - thanks!

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