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 1 commit
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
Expand Up @@ -4,6 +4,6 @@ namespace OrchardCore.ContentFields.Fields
{
public class ContentPickerField : ContentField
{
public string[] ContentItemIds { get; set; }
public string[] ContentItemIds { get; set; } = new string[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public string[] ContentItemIds { get; set; } = new string[0];
public string[] ContentItemIds { get; set; } = Array.Empty<string>();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just waiting for the CI to go green, but it's queued

}
}