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

InputTagHelper respect name override from IModelNameProvider.Name in ModelExpression #40182

Open
1 task done
msschl opened this issue Feb 12, 2022 · 3 comments
Open
1 task done
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one
Milestone

Comments

@msschl
Copy link
Contributor

msschl commented Feb 12, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Let's imagen the following page model:

public class IndexModel : PageModel
{
    [BindProperty(SupportsGet = true, Name = "public_name")]
    public string? InternalUsedParameterName { get; set; }

    public async Task<IActionResult> OnGetAsync()
    { }

    public async Task<IActionResult> OnPostAsync()
    { }
}
@page "/"
@model IndexModel

<form class="container" asp-page="/Index" method="post">
    <input type="hidden" asp-for="@Model.InternalUsedParameterName " />
</form>

Describe the solution you'd like

While rendering the InputTagHelper should respect the name set by the IModelNameProvider.Name property and set the id and name html attributes accordingly.

Additional context

No response

@msschl msschl changed the title InputTagHelper respect name override from IModelNameProvider in ModelExpression InputTagHelper respect name override from IModelNameProvider.Name in ModelExpression Feb 12, 2022
@msschl
Copy link
Contributor Author

msschl commented Feb 12, 2022

Setting the Name on the attribute otherwise would break model binding in correlation to using the InputTagHelper

@msschl
Copy link
Contributor Author

msschl commented Feb 12, 2022

I know the current workaround which is setting the name and id attributes in the html. However, I find the proposal above more elegant.

@page "/"
@model IndexModel

<form class="container" asp-page="/Index" method="post">
    <input type="hidden" name="public_name" id="public_name" asp-for="@Model.InternalUsedParameterName " />
</form>

@TanayParikh TanayParikh added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 13, 2022
@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Feb 14, 2022
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Feb 14, 2022
@ghost
Copy link

ghost commented Feb 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates 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

3 participants