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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

From ManyManyComplexTableField to ManyManyDataObjectManager


Go to End


3 Posts   1862 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, 4102 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!