|
I'm coming back to Orchard after a long break and it seems like all properties on my ViewModels are now required by default. I looked back at some old code and I had 4 properties on a view model, 2 with [Required] attribute and 2 without. I think this used to work that only the decorated 2 were actually required during the save/update process... but if I try to submit with all values empty, all 4 properties show a "Required" error message when I only expect 2 of them to be required. I can sort of fix it by putting the ValidateNeverAttribute on the properties that aren't required but this seems weird and wrong. Has Orchard had some changes in this area? Are [Required] attributes on the view model properties still a correct way to do validation? |
Replies: 4 comments
It depends on which |
|
Not sure if this is related to orchard core! It may be just .net related to nullable. For example, If you are using string (and not string?) without defining required attribute it will expect not null string |
The one used by the view used to edit my part e.g for MyPart there is usually a /Views/MyPart.Edit.cshtml file with |
|
Thanks @ns8482e, that was it. I really appreciate your help! |
Not sure if this is related to orchard core! It may be just .net related to nullable.
For example, If you are using string (and not string?) without defining required attribute it will expect not null string