Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize content picker field with empty array #3247

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>();
}
}