Hi Noel,
Your best bet would be to modify the way those lists render (though I tend to run screaming from anything that involves touching Dojo). Grzegorz Wiecheć put together an example of how you can modify that view here:
https://gregwiechec.com/2015/12/propertylist-with-images/
As a simple but not so good alternative option you might want to consider something like the following:
public class ArticleAttachment { private Injected<IContentLoader> _contentLoader; public ContentReference Attachment { get; set; } [ScaffoldColumn(false)] public string AttachmentName { get { return ContentReference.IsNullOrEmpty(Attachment) ? "" : _contentLoader.Service.Get<IContent>(Attachment).Name; } } public string LinkText { get; set; } }
However, this will only run when you open the page in the editor so will help people coming back to the page in the editor but won't update as items are added.
As a final option, do you need add additional data to go with your attachment per usage of that attachment? If not, you could add the properties (e.g. LinkText) to your DocumentFile model and just use a ContentReferenceList instead of your PropertyList. When rendering the list you could then pull out the relevant properties from the DocumentFile rather than the list item.
In this case I would use a regular link list. You can select a file and specify a link text.
public virtual LinkItemCollection ArticleAttachments { get; set; }
Not sure if it supports AllowedTypes though, but might be worth a try.
I'd certainly be tempted to use a LinkItemCollection and I was tempted to mention it in my reply but, according to the docs, it doesn't support the AllowedTypes attribute so, if the list has to be limited to items of type DocumentFile, you'd need a custom validator or similar to enforce that.
I would use it anyway, that editor has a better user experience. And as you mentioned - you can always have custom validation or just filter the items before displaying them.
Also would like to add that PropertyList<T> with complex types is still in beta.
I thought that came out of beta here:
https://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=CMS-7212
I'm using a PropertyList to let editors add a list of documents they wish to attach to the current article, but the editor experience in the 'all properties' screen leaves much to be desired and I was wondering if there is anything I can do to fix that?
As you can see from the above, "Attachment" just shows the Content Reference ID, which isn't very descriptive, combined with the fact that at the moment the 'adding items dialog' is letting editors add items not supported by the field :
[UIHint(UIHint.MediaFile)] [AllowedTypes(typeof(DocumentFile))] public virtual ContentReference Attachment { get; set; }
but after the editor adds the item, a vague and general validation message:
So, all in all, it would be really good if when they add the document, instead of display "56" it displayed "your_file-name~inHere.docx"
Is this possible?