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.

Data Model Questions /

Listing dataobjects with ListboxField


Reply


415 Views

Avatar
sweetroll

Community Member, 1 Post

4 September 2012 at 7:28pm

Hey,

I have a many to many relationship between a DataObject (Tag) and a Page and am wanting to manage the relationship through a multiple select.

At the moment I am stuck with the following code

$tagsField = new ListboxField(
'Tags',
'Tags',
Tag::get()->toArray("ID", "Name"),
$this->Tags()->toArray("ID", "Name"),
null,
true
);

Error: Object->__call(): the method 'fortemplate' does not exist on 'Tag'

I know this code won't currently allow me to add new tags but I would like to get my head around how to link existing tags with a page.

Hopefully I am not too far off.

Cheers.