如何在Orchard自定义模块中创建MediaLibraryPicker字段

时间:2013-12-13 10:21:40

标签: orchardcms orchardcms-1.7

我在自定义模块中添加了MediaLibraryPicker字段,我想要使这个字段成为必需。请帮我。 ContentDefinitionManager.AlterPartDefinition("UserProfilePart", part => part .WithField("Photo", field => field .OfType("MediaLibraryPickerField") .WithDisplayName("User Photo")));

提交表格时。用户需要从媒体库中选择至少一个图像。

2 个答案:

答案 0 :(得分:2)

我添加了MediaLibrary Picker Field的设置并且工作正常。

ContentDefinitionManager.AlterPartDefinition("UserProfilePart", part => part
     .WithField("Photo", field => field .OfType("MediaLibraryPickerField"
     .WithDisplayName("User Photo").WithSetting("MediaLibraryPickerFieldSettings.Required", "true")))

答案 1 :(得分:1)

添加.WithSetting(“必需”,“真”)