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   4354 Views

Avatar
cardinale

Community Member, 23 Posts

7 April 2009 at 4:37am

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

Community Member, 66 Posts

17 September 2009 at 4:39am

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

Community Member, 19 Posts

27 March 2010 at 5:20am

Edited: 27/03/2010 5:21am

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

Avatar
cardinale

Community Member, 23 Posts

27 March 2010 at 5:41am

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

Community Member, 2 Posts

29 June 2010 at 8:14am

Has there been a fix for this?

Avatar
Mr. Neave

Community Member, 8 Posts

12 January 2011 at 2:49pm

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

Community Member, 26 Posts

10 February 2011 at 6:13am

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

Avatar
AlphaCactus

Community Member, 11 Posts

12 February 2011 at 11:31am

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