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.

Customising the CMS

ManyManyComplexTableField in Popup


Go to End
Reply

11 Posts   4339 Views

Avatar
cardinale

7 April 2009 at 4:37am Community Member, 23 Posts

Hello, Can I open a ManyManyComplexTableField in a Popup in CMS to administrate relations. I tried it but it doesn't work, if I click the "Save" button the selections in the Table are not saved. Here is my code:

<?php
class ArztPage extends Page{
   
   static $has_many = array(
      'Aerzte' => 'Arzt',
   );

function getCMSFields() {
$fields = parent::getCMSFields();

      $AerzteTable = new ComplexTableField(
      $this, 'Aerzte', 'Arzt', null, null, "Arzt.ArztPageID = {$this->ID}");
   $fields->addFieldToTab( 'Root.Content.Ärzte', $AerzteTable );

return $fields;
}

..........

class Arzt extends DataObject {

      
   static $has_one = array(
      'ArztPage' => 'ArztPage'
);

static $many_many = array(
      'Vereinigungen' => 'Vereinigungen'
   );
   
   
function getCMSFields() {
      $fields = parent::getCMSFields();
      // add categories tab..
      $vereinTablefield = new ManyManyComplexTableField(
         $this,
         'Vereinigungen',
         'Vereinigungen',
         array( 'Name' => 'Name' )
         );

      $fields->addFieldToTab( 'Root.Main', $vereinTablefield );
      return $fields;
   }

}
.............

class Vereinigungen extends DataObject {

   static $db = array(
      'Name' => 'Varchar(255)'
      );
      
   static $has_one = array(
      'Bild' => 'Image'
   );

   static $belongs_many_many = array(
      'Aerzte' => 'Arzt'
   );
   
}

Avatar
dynamite

17 September 2009 at 4:39am Community Member, 66 Posts

I have the same problem with the pop-up not working; the link to add opens right over top of the CMS.

Did you find a solution to the problem? Thank you!

Avatar
cake

27 March 2010 at 5:20am (Last edited: 27 March 2010 5:21am), Community Member, 19 Posts

Has anyone a solution for this yet? I've got the same problem here.

Avatar
cardinale

27 March 2010 at 5:41am Community Member, 23 Posts

You can get it work with CheckboxSetField!

function getCMSFields() {
      $fields = parent::getCMSFields();   
      
      if($this->ID) {
         $ergebnis = new CheckboxSetField(
                'Empfaenger', 'Empfaenger',
                DataObject::get('Endkunde', 'DepositaerID = "'.$this->Depositaer()->ID.'"' ),
                $this->getManyManyComponents('Empfaenger') );                   
      } else {
         $ergebnis = new HeaderField("Empfänger können erst nach dem Speichern ausgewählt werden!", 3);
   }
      
      $fields->addFieldToTab('Root.Empfaenger', $ergebnis );
   
      return $fields;
   }

Avatar
fyodore

29 June 2010 at 8:14am Community Member, 2 Posts

Has there been a fix for this?

Avatar
Mr. Neave

12 January 2011 at 2:49pm Community Member, 8 Posts

Bump!

Ticking the checkboxes in a ManyManyComplexTablefield correctly saves a relationship as you would expect, provided that the ManyManyComplexTablefield is used outside of a popup.

But if the ManyManyComplexTablefield is _inside_ a popup, ticking the checkboxes then clicking 'Save' has no effect. The checkboxes revert to their previous state.

Anyone have a fix for this?

Avatar
Bright Eyes David

10 February 2011 at 6:13am Community Member, 26 Posts

Same problem here. ManyManyComplexTablefield doesn't save ticked items.

Avatar
AlphaCactus

12 February 2011 at 11:31am Community Member, 11 Posts

Also have same issue with ManyManyComplexTableField in a popup. I'm attempting to use it in the popup when editing a member.

Go to Top