Code Requirements
The editform as displayed below requires the following code:
XML
@inject IContactsService Service
<EZFormHeader TModel="Contact" Recordset="_recordset" />
<EZEditForm TModel="Contact" Recordset="_recordset" ShowMultipleRecords="false"
AllowAdditions="false">
<EZFormSelector TModel="Contact" >
<EZInput @bind-Value="context.Id" />
<EZInput @bind-Value="context.Name" FirstFocus="true" />
<EZInput @bind-Value="context.Birthday" />
<EZInput @bind-Value="context.Score" />
<EZInput @bind-Value="context.Address" />
<EZInput @bind-Value="context.PostalCode" />
<EZInput @bind-Value="context.City" />
</EZFormSelector>
</EZEditForm>
<EZFormNewRecord TModel="Contact" Recordset="_recordset" />
<EZFormFooter TModel="Contact" Recordset="_recordset" />
@code {
[Parameter] public int? Id { get; set; }
private EZRecordset<Contact>? _recordset;
protected async override Task OnInitializedAsync()
{
if (Id is not null)
{
_recordset = new(new EZRecordsetConfiguration<Contact>(Service)
{
WhereFunc = w => w.Id == Id
});
}
else
{
_recordset = new(new EZRecordsetConfiguration<Contact>(Service));
}
await base.OnInitializedAsync();
}
}
Loading...