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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

From ManyManyComplexTableField to ManyManyDataObjectManager


Reply


3 Posts   1433 Views

Avatar
BlueO

Community Member, 52 Posts

18 September 2010 at 8:44pm

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

Avatar
UncleCheese

Forum Moderator, 4094 Posts

25 September 2010 at 4:41am

You're using MySQL?

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

Avatar
BlueO

Community Member, 52 Posts

27 September 2010 at 9:55am

Oh man, yeap I was using sqlite - thanks!