0
votes

To add prefiled item with toolbar I can use this code:

@Edit.Toolbar(actions: "new", contentType: "Marker", prefill: new { Position = 65 } )

But If I have player entity with Markers (list of Marker), and want to create toolbar button to create new marker and add it to markers collection. What is the posible way to do that?

In sql you have same parent field or something but here I don't have any ideas where to start.

I also attached 2 screens for better understanding.

Edit player entity

Main screen

Now I have this code for adding custom button, but don't know what javascript to use and how and if this is a right direction...

<ul class="sc-menu" data-toolbar='{
    "groups": [{ 
        "buttons": [{ 
            "command": { 
                "action": "custom", 
                "customCode": "alert(\"add marker with current time!\")"
            },
            "icon": "icon-sxc-plus",
            "title": "Add marker"
        }]
    }]
}'></ul>
1
I found that table ToSIC_EAV_EntityRelationships contain relationship information, but still don't know how to add record to this table... I know how to get values for AttributeID, ParentEntityID, ChildEntityID and SortOrder, but think that adding record directly to this sql table is wrong way - Jernej Pirc
I also tryed : @Edit.Toolbar(actions: "new", contentType: "Marker", prefill: new { Position = 65, ParentEntityID = 3199 } ) // where 3199 is parent entity id but when I saved item it wasn't conected... - Jernej Pirc
One solution is that I remove Markers entity from Player and "manualy" manage relationship with hiden prefilled parent id field. But Then I cant manage this with default admin UI. (is this the only way?) - Jernej Pirc

1 Answers

0
votes

This can be done but I would have to spend some more time figuring it out. as far as I remember, you can just prefill an array - and there use the entity-id or the entity guid or even the title of the related items.