mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
* Custom Forms * Update BTCPayServer.Data/Migrations/20230125085242_AddForms.cs * Cleanups * Explain public form * Add store branding * Add form name to POS form * add tests * fix migration * Minor cleanups * Code improvements * Add form validation Closes #4317. * Adapt form validation for Bootstrap 5 * update logic for forms * pr changes * Minor code cleanup * Remove unused parameters * Refactor Form data handling to avoid O(n3) issues * Rename Hidden to Constant * Pre-populate FormView from the query string params * Fix test --------- Co-authored-by: d11n <mail@dennisreimann.de> Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
26 lines
1.2 KiB
Text
26 lines
1.2 KiB
Text
@model BTCPayServer.Abstractions.Form.Field
|
|
@{
|
|
var isInvalid = ViewContext.ModelState[Model.Name]?.ValidationState is Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid;
|
|
var errors = isInvalid ? ViewContext.ModelState[Model.Name].Errors : null;
|
|
}
|
|
<div class="form-group">
|
|
<label class="form-label" for="@Model.Name"@(Model.Required ? " data-required" : "")>
|
|
@Model.Label
|
|
</label>
|
|
<input id="@Model.Name" type="@Model.Type" class="form-control @(errors is null ? "" : "is-invalid")"
|
|
name="@Model.Name" value="@Model.Value" data-val="true"
|
|
@if (!string.IsNullOrEmpty(Model.HelpText))
|
|
{
|
|
@Safe.Raw($" aria-describedby=\"HelpText-{Model.Name}\"")
|
|
}
|
|
@if (Model.Required)
|
|
{
|
|
@Safe.Raw($" data-val-required=\"{Model.Label} is required.\" required")
|
|
}
|
|
/>
|
|
<span class="text-danger" data-valmsg-for="@Model.Name" data-valmsg-replace="true">@(isInvalid && errors.Any() ? errors.First().ErrorMessage : string.Empty)</span>
|
|
@if (!string.IsNullOrEmpty(Model.HelpText))
|
|
{
|
|
<div id="@($"HelpText-{Model.Name}")" class="form-text">@Model.HelpText</div>
|
|
}
|
|
</div>
|