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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Relation between Dataobjects - missing "add link" in popup


Go to End


5 Posts   2693 Views

Avatar
markus85

Community Member, 12 Posts

25 January 2011 at 12:48am

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
Avatar
swaiba

Forum Moderator, 1899 Posts

25 January 2011 at 3:34am

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

Avatar
markus85

Community Member, 12 Posts

25 January 2011 at 4:23am

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

Avatar
swaiba

Forum Moderator, 1899 Posts

25 January 2011 at 4:27am

Edited: 25/01/2011 4:28am

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

Avatar
markus85

Community Member, 12 Posts

25 January 2011 at 5:39am

Edited: 25/01/2011 5:40am

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>