Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ManyManyComplexTableField in Popup

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

Page: 1 2
Go to End
Author Topic: 4293 Views
  • cardinale
    Avatar
    Community Member
    23 Posts

    ManyManyComplexTableField in Popup Link to this post

    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'
       );
       
    }

  • dynamite
    Avatar
    Community Member
    66 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

    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!

  • cake
    Avatar
    Community Member
    19 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

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

  • cardinale
    Avatar
    Community Member
    23 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

    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;
       }

  • fyodore
    Avatar
    Community Member
    2 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

    Has there been a fix for this?

  • Mr. Neave
    Avatar
    Community Member
    8 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

    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?

  • Bright Eyes David
    Avatar
    Community Member
    26 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

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

  • AlphaCactus
    Avatar
    Community Member
    11 Posts

    Re: ManyManyComplexTableField in Popup Link to this post

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

    4293 Views
Page: 1 2
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.