Skip to content

Commit

Permalink
Initialize content picker field with empty array (#3247)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshawkins authored and sebastienros committed Feb 27, 2019
1 parent 251a036 commit 448befd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public override IDisplayResult Edit(ContentPickerField field, BuildFieldEditorCo
{
return Initialize<EditContentPickerFieldViewModel>(GetEditorShapeType(context), async model =>
{
model.ContentItemIds = field.ContentItemIds == null ? string.Empty : string.Join(",", field.ContentItemIds);
model.ContentItemIds = string.Join(",", field.ContentItemIds);
model.Field = field;
model.Part = context.ContentPart;
model.PartFieldDefinition = context.PartFieldDefinition;
model.SelectedItems = new List<ContentPickerItemViewModel>();
foreach (var contentItemId in field.ContentItemIds ?? new string[0])
foreach (var contentItemId in field.ContentItemIds)
{
var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using OrchardCore.ContentManagement;

namespace OrchardCore.ContentFields.Fields
{
public class ContentPickerField : ContentField
{
public string[] ContentItemIds { get; set; }
public string[] ContentItemIds { get; set; } = Array.Empty<string>();
}
}

0 comments on commit 448befd

Please sign in to comment.