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.

Archive /

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

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

Problems with $belongs_many_many


Reply


1142 Views

Avatar
Ney

Community Member, 8 Posts

8 April 2008 at 8:23pm

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(
         $this,
         'ChildProducts',
         'Product',
         array(
            
            'Title'=>'Title',
            'Price' => 'Price',
            'Weight'=>'Weight',   
            'Model'=> 'Author',
            'Content'=>'Content'
            ),
         'getCMSFields_forPopup',
         "ParentID = {$this->ID} AND ShowInMenus = 1 "
         );
      $tablefield->relationAutoSetting = true;
       $tablefield->setAddTitle( 'Products Details' );
      $fields->addFieldToTab("Root.Content.Products", $tablefield);
      return $fields;
   }