Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Problems with $belongs_many_many

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: 1090 Views
  • Ney
    Community Member
    8 Posts

    Problems with $belongs_many_many Link to this post

    hello friends I have a litter bit problem and I want to know if it possible to solve it!!
    I want to put the products in a tab inside ProductGroup and not in the tree, it is working but when I want to save the ProductGroup or Publish it an error appears!! this is my code could you help with this, thank u, the problem can be in the type of relationship but I don't know how to solve it!!

    class ProductGroup extends Page {
       static $add_action = 'a Product Group Page';
       static $casting = array();
       static $allowed_children = array("Product", "ProductGroup");
       static $default_child = 'Product';
       static $icon = "cms/images/treeicons/folder";

       static $db = array();

       static $belongs_many_many = array(
          "ChildProducts" => "Product"

       function getCMSFields() {
          $fields = parent::getCMSFields();
          // standard extra fields like weight and price
          $tablefield = new HasManyComplexTableField(
                'Price' => 'Price',
                'Model'=> 'Author',
             "ParentID = {$this->ID} AND ShowInMenus = 1 "
          $tablefield->relationAutoSetting = true;
           $tablefield->setAddTitle( 'Products Details' );
          $fields->addFieldToTab("Root.Content.Products", $tablefield);
          return $fields;

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.