Jump to:

23002 Posts in 11855 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Relation between Dataobjects - missing "add link" in popup

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1097 Views
  • markus85
    Avatar
    Community Member
    12 Posts

    Relation between Dataobjects - missing "add link" in popup Link to this post

    Hello out there,

    I have the following question:

    I have 3 classes
    One Page called “Saison”
    Two DataObject called “Spiel” and “Punkt”

    The relations are:
    One “Saison” has_many “Spiel”
    One “Spiel” has one “Saison”

    One “Spiel “ has many “Punkt”
    One “Punkt” has one “Spiel”

    I want to add “Spiel” and “Punkt” via the CMS. I added a ComplexTableField to “Saison” to edit the “Spiel” records. This works fine I can create, edit and delete “Spiel” records.

    If I click on one of these “Spiel” records a Popup-appears with two tabs  “Main” and “Punkt” in Main I can edit the “Spiel” Record.
    In the Tab “Punkt” I can just see the existing “Punkt” records.
    Is there a possibility to add new “Punkt” records in this Tab?

    This would be a very nice solution

    See the attachment for a screenshot

    Regards

    Attached Files
  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Relation between Dataobjects - missing "add link" in popup Link to this post

    possibly need to make the CTF yourself... something like...

    $cos = $this->Spiel();
    $ctf= new HasManyComplexTableField($this,'Punkt','Punkt',null,null,'ID IN ('.implode(',',$cos->getIdList()).')');
    $ctf->setPermissions(array('add','edit','show'));
    $ctf->Markable = false;
    $fields->addFieldToTab("Root.NewPunkt", $ctf);

  • markus85
    Avatar
    Community Member
    12 Posts

    Re: Relation between Dataobjects - missing "add link" in popup Link to this post

    thanks for the quick reply,

    one question on your code:

    what is $cos = $this->Spiel() doing ?
    there is no "Spiel()" function in this class...

    I tried this code without the $cos variable and there is still no "add" link in the TableField

    I just read the permission-array by $ar = $ctf->getPermissions(); the permissions are set like in your code..

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Relation between Dataobjects - missing "add link" in popup Link to this post

    >> what is $cos = $this->Spiel() doing ?

    when you define a relationship like has_one or has_many (many_many is different I think) you can use the relationshipname as a function to return the componet/componetset (like a dataobjectset but a couple more functions).

    sorry I can't help more - perhaps if you made your code into minimum required to reproduce the issue...

  • markus85
    Avatar
    Community Member
    12 Posts

    Re: Relation between Dataobjects - missing "add link" in popup Link to this post

    thanks for you reply, sure you can have a look on the code this isn´t top secrect project for the NASA but I just copied you code

    now it´s getting tricky

    I just looked on the code of the dialog, there you will find the add button, but you can´t see the button

    here is a little snippet from the code:

    <td colspan="1">
                   <input id="ComplexTableField_Popup_DetailForm_Strafe_PopupHeight" value="390" disabled="disabled" type="hidden">
                   <input id="ComplexTableField_Popup_DetailForm_Strafe_PopupWidth" value="560" disabled="disabled" type="hidden">

                   <a style="display: none;" class="popuplink addlink" href="admin/EditForm/field/Spiel/item/1/DetailForm/field/Strafe/add?SecurityID=5d98310200969de2002bd585b34f2e0f627f5548&amp;SecurityID=5d98310200969de2002bd585b34f2e0f627f5548" alt="add"><img src="cms/images/add.gif" alt="%s hinzufügen">
                      &lt;% sprintf(_t('ADDITEM', 'Add %s', PR_MEDIUM, 'Add [name]'),Strafe) %&gt;
                   </a>
                </td>

    1097 Views
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.