-
Notifications
You must be signed in to change notification settings - Fork 380
/
BasicFormBlazorComponents.razor
79 lines (69 loc) · 2.31 KB
/
BasicFormBlazorComponents.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@page "/basicform-blazor-components"
<PageTitle>@App.PageTitle("Basic Form Blazor")</PageTitle>
<h1>Starfleet Starship Database</h1>
<h2>New Ship Entry Form</h2>
<EditForm Model="@starship" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label>
Identifier:
<InputText @bind-Value="starship.Identifier" />
<ValidationMessage For="@(() => starship.Identifier)" />
</label>
</p>
<p>
<label>
Description (optional):
<InputTextArea @bind-Value="starship.Description" />
<ValidationMessage For="@(() => starship.Description)" />
</label>
</p>
<p>
<label>
Primary Classification:
<InputSelect @bind-Value="starship.Classification">
<option value="">Select classification ...</option>
<option value="Exploration">Exploration</option>
<option value="Diplomacy">Diplomacy</option>
<option value="Defense">Defense</option>
</InputSelect>
<ValidationMessage For="@(() => starship.Classification)" />
</label>
</p>
<p>
<label>
Maximum Accommodation:
<InputNumber @bind-Value="starship.MaximumAccommodation" />
<ValidationMessage For="@(() => starship.MaximumAccommodation)" />
</label>
</p>
<p>
<label>
Engineering Approval:
<InputCheckbox @bind-Value="starship.IsValidatedDesign" />
<ValidationMessage For="@(() => starship.IsValidatedDesign)" />
</label>
</p>
<p>
<label>
Production Date:
<InputDate @bind-Value="starship.ProductionDate" />
<ValidationMessage For="@(() => starship.ProductionDate)" />
</label>
</p>
<button type="submit">Submit</button>
<p>
<a href="http://www.startrek.com/">Star Trek</a>,
©1966-2019 CBS Studios, Inc. and
<a href="https://www.paramount.com">Paramount Pictures</a>
</p>
</EditForm>
@code {
private Starship starship = new() { ProductionDate = DateTime.Now };
private void HandleValidSubmit()
{
DemoLogger.WriteLine("HandleValidSubmit called");
// Process the valid form
}
}