Developer forum

Forum » Dynamicweb 10 » Code first items collection not saved

Code first items collection not saved

Karol Barkowski
Reply

Hi,

I have defined a very simple "Department"  item type

And another one that serves pretty much as a container:

But whener I save this parent item, only the "Title" field is saved. My collection of "Departments" are gone.
I already checked permissions for both of them and I can confirm that those are ok (Departments map allow departments as child components as well as the other way around).
What am I missing here?

When I'm editing my parent component it seems like the editor is showing up properly. I can see the Title property along with the collection of Departments. And I can add them to that collection. But when I hit save, they're gone.

 


Replies

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply
This post has been marked as an answer

Hi Karol,

Field of type ItemRelationListEditor  should have int type:

public int Departments{ get; set; }

See example here https://doc.dynamicweb.dev/api/Dynamicweb.Content.Items.Annotations.ItemRelationListAttribute.html

Best rregards,
Vladimir

Votes for this answer: 1
 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply
This post has been marked as an answer

PS:  The int value here is id of https://doc.dynamicweb.dev/api/Dynamicweb.Content.Items.ItemList.html
   var list = ItemList.GetItemListById(Departments);
   var listItems = list.Relations;

Best regards,
Vladimir

Votes for this answer: 1
 
Karol Barkowski
Reply

Works great now.

Thank you.

 

You must be logged in to post in the forum