1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-23 19:42:51 +01:00
Minecraft-Phantom-Panel/Web/Phantom.Web.Components/Forms/FormSubmitError.razor

35 lines
825 B
Plaintext

@using Phantom.Web.Components.Utils
@if (messageLines.Length > 0) {
<div class="form-submit-errors text-danger" role="alert">
@for (int i = 0; i < messageLines.Length; i++) {
@messageLines[i]
if (i < messageLines.Length - 1) {
<br />
}
}
</div>
}
@code {
[CascadingParameter]
public Form? Form { get; set; }
[Parameter]
public FormButtonSubmit.SubmitModel? Model { get; set; }
[Parameter]
public string? Message { get; set; }
private string[] messageLines = Array.Empty<string>();
protected override void OnParametersSet() {
BlazorUtils.RequireEitherParameterIsSet(Form, Model);
var model = Form?.Model.SubmitModel ?? Model;
var message = model?.SubmitError ?? Message;
messageLines = message?.Split('\n') ?? Array.Empty<string>();
}
}