MediaLibraryPickerField can not work in front end

Topics: Core, General
Oct 4, 2013 at 3:49 AM
MediaLibraryPickerField can not work in front end( outside admin panel,for ex, on register page with User)
got object null at
public IEnumerable<MediaPart> MediaParts {
        get {
            return _contentItems.Value;
        }
    }
in
namespace Orchard.MediaLibrary.Fields {
public class MediaLibraryPickerField 
Coordinator
Oct 5, 2013 at 12:06 AM
What exactly are you trying to do?
Oct 5, 2013 at 1:03 AM
ContentDefinitionManager.AlterPartDefinition("ProfilePart",
              part => part
             .WithField("FirstName", field => field.OfType("InputField")
                 .WithSetting("InputFieldSettings.Type", "Text")
                .WithSetting("InputFieldSettings.Required", "true")
                .WithSetting("InputFieldSettings.MaxLength", "200")
             )
              .WithField("LastName", field => field.OfType("InputField")
                   .WithSetting("InputFieldSettings.Type", "Text")
                .WithSetting("InputFieldSettings.Required", "true")
                .WithSetting("InputFieldSettings.MaxLength", "200")
              )
             .WithField("Type", field => field.OfType("EnumerationField")
                     .WithSetting("EnumerationFieldSettings.Options", "Agent\r\nCompany\r\nOwner")
                     .WithSetting("EnumerationFieldSettings.Required", "false")
             )
              .WithField("Phone", field => field.OfType("InputField")
                   .WithSetting("InputFieldSettings.Type", "Tel")
                .WithSetting("InputFieldSettings.Required", "false")
              )
              .WithField("Fax", field => field.OfType("InputField")
                   .WithSetting("InputFieldSettings.Type", "Tel")
                .WithSetting("InputFieldSettings.Required", "false")
              )


              .WithField("Company", field => field.OfType("InputField")
                   .WithSetting("InputFieldSettings.Type", "Text")
                .WithSetting("InputFieldSettings.Required", "false")
                .WithSetting("InputFieldSettings.MaxLength", "100")
              )

             .WithField("UserImage", field => field.OfType("MediaLibraryPickerField")
                 .WithSetting("MediaLibraryPickerFieldSettings.DisplayedContentTypes", "User")
                 .WithSetting("MediaLibraryPickerFieldSettings.Required", "false")
                 .WithSetting("MediaLibraryPickerFieldSettings.Multiple", "false")
               )
          );
        return 1;

then, add ProfilePart to user type. then create register page