Skip to content

MultiSelect TagHelper has incorrect "name" attribute when its "id" attribute is changed #7990

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

Closed
kendo-bot opened this issue Sep 30, 2024 · 0 comments
Assignees
Milestone

Comments

@kendo-bot
Copy link
Collaborator

kendo-bot commented Sep 30, 2024

Bug report

When using the @Html.EditorFor(m => m) configuration to initialize a MultiSelect TagHelper editor, and passing a specified value for its "id" attribute, the "name" attribute of the <select> element contains a prefix.

Reproduction of the problem

  1. Set the MultiSelect TagHelper as an editor editor of a specified Model property and set the "id" attribute using ViewData:
//Model
[UIHint("CustomMultiSelect")]
public IEnumerable<string> Names { get; set; }

//~.Views/Shared/EditorTemplates/CustomMultiSelect.cshtml
@model IEnumerable<string>
@{
    var id = ViewData["id"]?.ToString();
}
<kendo-multiselect for="@Model" placeholder="some custom behavior" bind-to='ViewData["Data"] as List<string>' id='@id'></kendo-multiselect>
  1. Define @Html.EditorFor(a=>a.Names, new{id="customId"}) in a form:
@model MyModel
<form id="myForm" data-method="POST"  asp-action="Save" asp-controller="Home"  class="k-form k-form-md">
    <div class="k-form-layout k-d-grid">
        <div class="k-form-field">
            @Html.EditorFor(a=>a.Names, new{id="customId"})
        </div>
    </div>
    ...
</form>
  1. When the MultiSelect is loaded, its "name" attribute is "Names.Names" rather than "Names":

image

When using the HtmlHelper version of the MultiSelect, the "name" attribute is correct:

//~.Views/Shared/EditorTemplates/CustomMultiSelect.cshtml
@model IEnumerable<string>
@{
    var id = ViewData["id"]?.ToString();
}
@(Html.Kendo().MultiSelectFor(m => m)
  .Placeholder("some custom behavior")
  .BindTo((List<string>)ViewData["Data"])
  .HtmlAttributes(new { id = @id })
)

Expected/desired behavior

When using the @Html.EditorFor(m => m) configuration, the "name" attribute of the MultiSelect TagHelper must match the Model property name when the "id" attribute is set to a custom value.

Environment

  • **Telerik UI for ASP.NET Core version: 2024.3.806
  • **Browser: [all]
@kendo-bot kendo-bot added the FP: Unplanned Sync status with associated Feedback Item label Sep 30, 2024
@aleksandarevangelatov aleksandarevangelatov self-assigned this Oct 3, 2024
@Dimitar-Goshev Dimitar-Goshev added this to the 2024 Q4 (Nov) milestone Oct 30, 2024
@github-actions github-actions bot added FP: Completed Sync status with associated Feedback Item and removed FP: Unplanned Sync status with associated Feedback Item labels Oct 30, 2024
@Dimitar-Goshev Dimitar-Goshev added the Next Release Item that will be included in the next official release label Oct 30, 2024
@kendo-bot kendo-bot removed the Next Release Item that will be included in the next official release label Nov 13, 2024
@Dimitar-Goshev Dimitar-Goshev self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants