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

Add AbpIdNameTagHelper #6755

Merged
merged 2 commits into from
Dec 22, 2020
Merged

Add AbpIdNameTagHelper #6755

merged 2 commits into from
Dec 22, 2020

Conversation

maliming
Copy link
Member

@maliming maliming commented Dec 22, 2020

It can generate id and name based on expression. <input abp-id-name="@Model.Users[0].Name" />

public class IndexModel : PageModel
{
    public List<Test> Users { get; set; }

    public void OnGet()
    {
        Users = new List<Test>()
        {
            new Test()
            {
                Name = "1"
            },
            new Test()
            {
                Name = "2"
            }
        };
    }
}

public class Test
{
    public string Name { get; set; }
}

@for (var i = 0; i < Model.Users.Count; i++)
{
    var user = Model.Users[i];
	
    <abp-input asp-for="@user.Name" />
    <abp-input asp-for="@user.Name" abp-id-name="@Model.Users[i].Name" />
    <abp-input asp-for="@user.Name" id=@($"test{i.ToString()}") name=@($"test{i.ToString()}") abp-id-name="@Model.Users[i].Name" />
}
<div class="form-group"><label for="user_Name">Name</label><input type="text" id="user_Name" name="user.Name" value="1" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>
<div class="form-group"><label for="user_Name">Name</label><input id="Users_0__Name" name="Users[0].Name" type="text" value="1" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>
<div class="form-group"><label for="user_Name">Name</label><input id="test0" name="test0" type="text" value="1" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>
<div class="form-group"><label for="user_Name">Name</label><input type="text" id="user_Name" name="user.Name" value="2" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>
<div class="form-group"><label for="user_Name">Name</label><input id="Users_1__Name" name="Users[1].Name" type="text" value="2" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>
<div class="form-group"><label for="user_Name">Name</label><input id="test1" name="test1" type="text" value="2" class="form-control " /><span class="text-danger field-validation-valid" data-valmsg-for="user.Name" data-valmsg-replace="true"></span></div>

@maliming maliming added this to the 4.2-preview milestone Dec 22, 2020
@realLiangshiwei realLiangshiwei merged commit c9198e5 into dev Dec 22, 2020
@realLiangshiwei realLiangshiwei deleted the maliming/AbpIdNameTagHelper branch December 22, 2020 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants