-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Display(Order={i})]
ignored when sorting validation summary messages and properties in @Html.Display()
/ @Html.Editor()
object
templates
#964
Comments
In addition |
ModelMetadata.Order
based on attributes[Display(Order={i})]
ignored when sorting validation summary messages and properties in @Html.Display()
/ @Html.Editor()
object
templates
Main fix here is to set MVC 5.2 does not provide a predictable property order when displaying / editing a complex object or filling in the |
- supports useful property updates of `ModelMetadata` instances in the collection - provide a controllable ordering using the `Order` value - part of #964
- supports useful property updates of `ModelMetadata` instances in the collection - provide a controllable ordering using the `Order` value - part of #964
- supports useful property updates of `ModelMetadata` instances in the collection - provide a controllable ordering using the `Order` value - part of #964
- supports useful property updates of `ModelMetadata` instances in the collection - provide a controllable ordering using the `Order` value - part of #964
…perty order #964 - compute `ModelMetadata.Order` based on `[Display]` attribute - property affects e.g. `@Html.DisplayFor()` generation for complex objects - also affects order of messages in validation summary - use `PropertyName` to make overall order predictable - update existing tests to match new property order - test new scenarios involving `ModelMetadata.Order` - per-property `ModelMetadata` and related tests - validation and `HtmlHelper` tests - add `HtmlHelperValidationSummaryTest` (which touches on #453) - update ModelBinding functional test to show use of `[Display(Order = x)]` nits: - remove some trailing whitespace - move more `NullDisplayText` bits into proper slots (just above `Order`) - avoid `Assert.True()` & `Assert.False()`; split some assertions up - add more assertions in tests involving `ModelStateDictionary.CanAddErrors` - `""` -> `string.Empty` in affected test classes - rename "DefaultEditorTemplatesTest~~s~~" class and file to follow guidelines - rename "ModelBindingTest~~s~~" class and file to follow guidelines
…perty order #964 - compute `ModelMetadata.Order` based on `[Display]` attribute - property affects e.g. `@Html.DisplayFor()` generation for complex objects - also affects order of messages in validation summary - use `PropertyName` to make overall order predictable - update existing tests to match new property order - test new scenarios involving `ModelMetadata.Order` - per-property `ModelMetadata` and related tests - validation and `HtmlHelper` tests - add `HtmlHelperValidationSummaryTest` (which touches on #453) - update ModelBinding functional test to show use of `[Display(Order = x)]` nits: - remove some trailing whitespace - move more `NullDisplayText` bits into proper slots (just above `Order`) - avoid `Assert.True()` & `Assert.False()`; split some assertions up - add more assertions in tests involving `ModelStateDictionary.CanAddErrors` - `""` -> `string.Empty` in affected test classes - rename "DefaultEditorTemplatesTest~~s~~" class and file to follow guidelines - rename "ModelBindingTest~~s~~" class and file to follow guidelines
- #964 - compute `ModelMetadata.Order` based on `[Display]` attribute - property affects e.g. `@Html.DisplayFor()` generation for complex objects - also affects order of messages in validation summaries - test new scenarios involving `ModelMetadata.Order` - per-property `ModelMetadata` and related tests - validation and `HtmlHelper` tests - add `HtmlHelperValidationSummaryTest` (which touches on #453) - update ModelBinding functional test to show use of `[Display(Order = x)]` nits: - move more `NullDisplayText` bits into proper slots (just above `Order`) - add doc comments for `ComputeNullDisplayText()` - add more assertions in tests using `ModelStateDictionary.HasReachedMaxErrors` - remove some trailing whitespace - avoid `Assert.True()` & `Assert.False()`; split some assertions up - `""` -> `string.Empty` in affected test classes - rename "DefaultEditorTemplatesTest~~s~~" class and file to follow guidelines - rename "ModelBindingTest~~s~~" class and file to follow guidelines FYI #1888 covers a predictable (or even just stable) order in the UI
fixed in commit 8779caf |
Using the attribute [Display(Order=x)] only allows developers to fix this proplem if the summary is showing errors for a single entity. This does not fix the problem for other scenarious such as when you wish to display errors for a collection of entities. The problem is simply fixed in this respect by displaying the errors in which they were added to the ModelErrorCollection which it currently does not! Your cracking a nut with a hammer - seemingly? |
This is a regression compared with MVC 5.2 and it's similar to #843, #844, #933, and #963. In this case however it's less than a functional gap; all the expected information is available. The visible symptoms are unpredictable ordering of validation errors and the
Properties
collection.The current implementation of
CachedModelMetadata<TPrototypeCache>
does not override theOrder
property as it should. Value should be based on[Display]
attributes in the model.The text was updated successfully, but these errors were encountered: