Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » many_many widget

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 926 Views
  • jam13
    121 Posts

    many_many widget Link to this post

    I'm trying to create a widget that has a many_many relationship with a page type:

    class RecipeWidget extends Widget {
    static $many_many = array(
    'FeaturedRecipes' => 'RecipePage'

    class RecipePage extends Page {
    static $belongs_many_many = array(
    'RecipeWidgets' => 'RecipeWidget'

    This seems to work (it creates the appropriate tables), so I tried to add a checkbox set to the CMSFields:

    class RecipeWidget extends Widget {
    function getCMSFields() {
    $myRecipes = DataObject::get('RecipePage');
    return new FieldSet(
    new CheckboxSetField('FeaturedRecipes', '', $myRecipes)

    which displays the checkbox set as requested. Unfortunately it doesn't save the selections

    Am I doing something wrong, or does this Field not work within a Widget?

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.