My question is simmalar to questions/10369967/orchard-cms-how-to-add-media-picker-field-to-anew-module
I've created a new content part, that has a select list, a text box and ... I want to include a media picker filed.
I have added this to the content part with Bertrand Le Roy's suggestion of:
ContentDefinitionManager.AlterPartDefinition("Product",
builder => builder.WithField("ProductImage",
fieldBuilder => fieldBuilder
.OfType("MediaPickerField")
.WithDisplayName("Product Image")));
However I've no idea of how to show this in my custom editor View
I'm sure there should be something easy like @Display(Model.ProductImage) ... but I've followed the writing a content part form the Orchard docs, and my model in my editor view is not dynamic.
So if such magic as @Display(Model.ProductImage) exists, how do I add the media picker item to my view model ?
Update
The Media picker field seems to be showing on the content types where I add this part, just not where I want it! I want to show / hide this field biased on values selected form a select list, How can I stop the default rendering of the field Content Item and Render it in my custom view ?
Update 2
I've added this in the model
public MediaPickerField MediaPicker
{
get{ return (MediaPickerField)((dynamic)ContentItem).HeaderPart.Image;}
}
this to the view
@Html.Partial("EditorTemplates/Fields/MediaPicker.Edit", Model.MediaPicker)
and this is the placement.info
<!-- MediaPicker -->
<Place Fields_MediaPicker_Edit="-"/>
Now it looks right on the editing via cms end... but dosen't seem to save the images to the database!