I am working on an Orchard site that needs to be able to use some customized forms to create new content items.
To handle this I'm using a controller to display a form and then trying to create the new content items on post back by populating the dynamic items and then sending them through the ContentManagerService's Create() function.
This is working ok until I got to the content picker field I have as part of my content item.
In my project I have a content type of Question Record that has a SubmittedBy field that is a Content Picker Field.
Here is what I can see in the immediate window while processing the post back:
> dynamic q = _questionService.NewQuestion("Why doesn't this work?"); {Custom.Website.Models.Question} base {Orchard.ContentManagement.ContentPart}: {Custom.Website.Models.Question} IsNew: true OriginalQuestion: "Why doesn't this work?" Summary: null > q.QuestionRecord {Orchard.ContentManagement.ContentPart} base {System.Dynamic.DynamicObject}: {Orchard.ContentManagement.ContentPart} ContentItem: {Orchard.ContentManagement.ContentItem} Fields: Count = 5 Id: 0 PartDefinition: {Orchard.ContentManagement.MetaData.Models.ContentPartDefinition} Settings: Count = 0 TypeDefinition: {Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition} TypePartDefinition: {Orchard.ContentManagement.MetaData.Models.ContentTypePartDefinition} Zones: {Orchard.UI.ZoneCollection} > q.QuestionRecord.SubmittedBy {Orchard.ContentPicker.Fields.ContentPickerField} base {Orchard.ContentManagement.ContentField}: {Orchard.ContentPicker.Fields.ContentPickerField} ContentItems: null Ids: {int[0]}
The ContentItems property is read-only and the Ids when assigning a new int[] to the Ids array I get a System.ObjectDisposedException with the message: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
Are there any workarounds to get this value set in code or do I need to create my own property to store the related content item ids? It would be very helpful to have the admin interface of the ContentPickerField also available.
Thanks.