My ViewModel has a property that is a collection of another of my model entities, in this case CategoryTags (and each tag has a Tag and an ID).
1) Am I correct in understanding that Html.EditorFor() doesn't have an UI it can create for an ICollection?
2) Assuming #1, I've decided to make an EditorTemplate that is a textbox where my user can key in comma-separated tag names and jquery will autocomplete. Will I have to pass back the list of tag names (or their respective IDs) and then parse them back into the CategoryTags propety on POST?
Thanks!
Edit for #2 - I read your original post a little incorrectly. If you put them all into a single textbox, then you will need to parse them (or create your own model binder). You could have an editor that adds new textboxes to the DOM for each item and then model binder will correctly repopulate the list. However in the case you mentioned, your options are manually do this on the server, or use your own model binder (which would be fairly easy here) to break them apart into a model. Either or : )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With