Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Listing dataobjects with ListboxField

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

Page: 1
Go to End
Author Topic: 369 Views
  • sweetroll
    Avatar
    Community Member
    1 Post

    Listing dataobjects with ListboxField Link to this post

    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.

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