EditForm in Blazor 中有两个输入选择,提交按钮似乎没有触发



我有两个inputselect,它们从两个表中获取它们的选项。它们的值写入另一个表,这个表基本上是一个查找表。因此,两个整数值和该行的ID。

@page "/utility/ptrh"
@inject IProviderTypeRespiteHomeRepo Repo
@inject IRespiteHomeRepo RhRepo
@inject IProviderTypeRepo PtRepo
@inject NavigationManager NavManager
@inject IToastService ToastService
<h3>Assign Provider Type to Respite Home</h3>
<EditForm Model="_model" OnSubmit="CreatePtrh">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group">
<label for="rh">Respite Home</label>
@*<InputNumber @bind-Value="_model.RespiteHomeId"></InputNumber>*@
<InputSelect @bind-Value="_model.RespiteHomeId" class="form-control" id="rh">
@if (_rhModel != null)
{
<option value="-1">select one</option>
@foreach (var rh in _rhModel)
{
<option value="@rh.ID">@rh.RespiteHomeName</option>
}
}
</InputSelect>
</div>
<div class="form-group">
<label for="pt">Provider Type</label>
@*<InputNumber @bind-Value="_model.ProviderTypeId"></InputNumber>*@
<InputSelect @bind-Value="_model.ProviderTypeId" class="form-control" id="pt">
@if (_ptModel != null)
{
<option value="-1">select one</option>
@foreach (var pt in _ptModel)
{
<option value="@pt.ID">@pt.ProviderTypeName</option>
}
}
</InputSelect>
</div>

<button class="btn btn-success" type="submit"><span class="oi oi-pencil"></span> Add Provider Type for Respite Home</button>
<button @onclick="BackToList" class="btn btn-outline-secondary">
<span class="oi oi-media-skip-backward"></span> Back to List
</button>
</EditForm>
@code {
private ProviderTypeRespiteHome _model = new ProviderTypeRespiteHome();
private IList<RespiteHome> _rhModel;
private IList<ProviderType> _ptModel;
private bool _isSuccess = true;
protected override async Task OnInitializedAsync()
{
_rhModel = await RhRepo.Get(Endpoints.RespiteHomeTypesEndpoint);
_ptModel = await PtRepo.Get(Endpoints.ProviderTypesEndpoint);
}
private async Task CreatePtrh()
{
_isSuccess = await Repo.Create(Endpoints.PTRHEndpoint, _model);
if (_isSuccess)
{
ToastService.ShowSuccess("PTRH record has been created.");
BackToList();
}
}
private void BackToList()
{
NavManager.NavigateTo("/respitehomes/");
}
}

我的数据模型是好的。它们从另外两个表中提取数据。就在我点击提交按钮时,什么也没发生。

帮助!其他创建剃刀页面几乎相同的标记工作!!!!

正如上面的评论,确保你的API中没有超过一个具有完全相同名称的控制器,即使它在另一个文件夹或子文件夹中。一旦删除,它就可以正常工作了。

相关内容

  • 没有找到相关文章

最新更新