Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

[DataType] and [DisplayFormat] ignored when choosing @Html.Display() and @Html.Editor() templates #933

Closed
dougbu opened this issue Aug 4, 2014 · 2 comments

Comments

@dougbu
Copy link
Member

dougbu commented Aug 4, 2014

This is a functional gap compared with MVC 5.2. For example it leads to incorrect templates for @Html.Display() and @Html.Editor().

The current implementation of CachedModelMetadata<TPrototypeCache> does not override the DataTypeName property as it should. Value should be based on [DataType] or (for the special case of the "html" choice) [DisplayFormat] attributes in the model.

@dougbu
Copy link
Member Author

dougbu commented Aug 13, 2014

Need to set ModelMetadata.DataTypeName based on attributes, as described above.

Between this bug and #963, only a few of the default templates get chosen automatically -- based just on the model's Type and whether it's a complex object or collection. Manual ModelMetadata changes are required to have the "Date", "DateTime-local", "EmailAddress", "HiddenInput", "Html", "Password", "PhoneNumber", "Time", or "Url" templates picked up.

@danroth27 danroth27 added this to the 6.0.0-beta1 milestone Sep 4, 2014
dougbu pushed a commit that referenced this issue Oct 1, 2014
- helps MVC helpers like `@Html.EditorFor()` select the correct template
- #933

nit:
- add XML doc for `DataTypeName` in base `ModelMetadata`
- an -> a in an adjacent XML comment in `CachedDataAnnotationsModelMetadata`
dougbu added a commit that referenced this issue Oct 1, 2014
- helps MVC helpers like `@Html.EditorFor()` select the correct template
- #933

nit: add XML doc for `DataTypeName` in base `ModelMetadata`
dougbu added a commit that referenced this issue Oct 3, 2014
- helps MVC helpers like `@Html.EditorFor()` select the correct template
- #933

nit: add XML doc for `DataTypeName` in base `ModelMetadata`
@dougbu
Copy link
Member Author

dougbu commented Oct 3, 2014

Fixed in commit a5600a7

@dougbu dougbu closed this as completed Oct 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants