Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisplayNameFor support in Blazor #49147

Open
danroth27 opened this issue Jul 2, 2023 · 6 comments
Open

DisplayNameFor support in Blazor #49147

danroth27 opened this issue Jul 2, 2023 · 6 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one
Milestone

Comments

@danroth27
Copy link
Member

MVC & Razor Pages have the DisplayNameFor HTML helper. Blazor doesn't currently have any helpers for creating a display name for model properties or expressions. This would be useful for scaffolding form field labels based on a model type, where you pick up the display name from attributes, like [Display(Name="Release date")], on the model. QuickGrid has some logic for displaying column headings based on a model type, but it doesn't support the DisplayAttribute.

@agriffard
Copy link

An attribute using a Resource key could be also useful to localize it.

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jul 3, 2023
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Jul 3, 2023
@ghost
Copy link

ghost commented Jul 3, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@guardrex
Copy link
Contributor

guardrex commented Aug 17, 2023

Side-note on my hitting this, too, while performing doc updates.

I was also going to cover it this way ...

[Required, DisplayName("Production Date")]
public DateTime ProductionDate { get; set; }

Both decorations ([Display] and [DisplayName]) aren't currently functional.

I'm going to place some guidance on those approaches, but I'll comment it out so that it won't appear right now and leave a tracking note in place to keep an 👁️ on the issue.

I can confirm that the DisplayName parameter on InputX components is working ✔️ ...

<InputDate @bind-Value="Model!.ProductionDate" DisplayName="Production Date" />

image

@GilShalit
Copy link

I find it strange that decorating class members with attributes and using those attributes in code (so central and useful in Razor pages) has been abasically dropped for Blazor. I would suggest this should be pushed forward if possible.

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Planning: WebUI, Backlog Nov 25, 2023
@dotnet dotnet deleted a comment Nov 25, 2023
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@flatproject
Copy link

It doesnt look like it will make it it in .Net9 since its not in the planning doc, hoping for .Net 10......

@guardrex
Copy link
Contributor

Noting that there are related open issues (and a closed PR) on this subject ...

@danroth27 ... I hit this again for the new tutorial. I think subclassing PropertyColumn is going too far for an introductory tutorial, so I'll just have the dev set the Title of the column in the QuickGrid. However, I have opened an issue for the QuickGrid article to add a section to the article on how to subclass PropertyColumn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

7 participants