-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.razor
95 lines (91 loc) · 4.51 KB
/
Index.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@page "/"
@using System.ComponentModel.DataAnnotations;
<EditForm Model="@userData"
Context="EditFormContext"
OnInvalidSubmit="@HandleInvalidSubmit">
<DataAnnotationsValidator />
<div>
<DxFormLayout CssClass="my-form-layout" ItemCaptionAlignment="ItemCaptionAlignment.All">
<DxFormLayoutGroup Caption="Personal Information"
ExpandButtonDisplayMode="GroupExpandButtonDisplayMode.End"
@bind-Expanded="@PersonalExpanded"
ExpandButtonIconCssClass="btn-icon"
CollapseButtonIconCssClass="btn-icon revert-icon">
<DxFormLayoutItem Caption="First Name:" ColSpanMd="12">
<DxTextBox @bind-Text="@userData.FirstName" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Last Name:" ColSpanMd="12">
<DxTextBox @bind-Text="@userData.LastName" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Age:" ColSpanMd="12">
<DxSpinEdit @bind-Value="@userData.Age" MinValue="0"></DxSpinEdit>
</DxFormLayoutItem>
</DxFormLayoutGroup>
<DxFormLayoutGroup Caption="Work Information"
ExpandButtonDisplayMode="GroupExpandButtonDisplayMode.End"
@bind-Expanded="@WorkExpanded"
ExpandButtonIconCssClass="btn-icon"
CollapseButtonIconCssClass="btn-icon revert-icon">
<DxFormLayoutItem Caption="Company Name:" ColSpanMd="12">
<DxTextBox @bind-Text="@userData.CompanyName" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Industry:" ColSpanMd="12">
<DxSpinEdit @bind-Value="@userData.Industry"></DxSpinEdit>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Position:" ColSpanMd="12">
<DxTextBox @bind-Text="@userData.Position" />
</DxFormLayoutItem>
</DxFormLayoutGroup>
<DxFormLayoutGroup Caption="Contact Information"
ExpandButtonDisplayMode="GroupExpandButtonDisplayMode.End"
@bind-Expanded="@ContactExpanded"
ExpandButtonIconCssClass="btn-icon"
CollapseButtonIconCssClass="btn-icon revert-icon">
<DxFormLayoutItem Caption="Email:" ColSpanMd="12">
<DxMaskedInput @bind-Value="@userData.Email"
Mask="@EmailMask"
MaskMode="MaskMode.RegEx">
<DxRegExMaskProperties InvalidInputNotificationText="Email is invalid" />
</DxMaskedInput>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Phone Number:" ColSpanMd="12">
<DxMaskedInput @bind-Value="@userData.PhoneNumber"
Mask="(999)000-0000">
<DxTextMaskProperties InvalidInputNotificationText="Phone number is invalid"></DxTextMaskProperties>
</DxMaskedInput>
</DxFormLayoutItem>
</DxFormLayoutGroup>
<DxFormLayoutItem ColSpanMd="12">
<ValidationSummary />
</DxFormLayoutItem>
</DxFormLayout>
</div>
<DxButton Text="Submit" SubmitFormOnClick="true"></DxButton>
</EditForm>
@code {
bool PersonalExpanded { get; set; } = true;
bool WorkExpanded { get; set; } = false;
bool ContactExpanded { get; set; } = false;
void HandleInvalidSubmit(EditContext editContext) {
PersonalExpanded = true;
WorkExpanded = true;
ContactExpanded = true;
}
string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
UserObject userData = new UserObject();
public class UserObject {
public int Id { get; set; }
[Required]
public string? FirstName { get; set; }
[Required]
public string? LastName { get; set; }
[Range(18, 100000, ErrorMessage = "You must be older than 18 years")]
public int Age { get; set; }
[Required]
public string? CompanyName { get; set; }
public int Industry { get; set; }
public string? Position { get; set; }
public string? Email { get; set; }
public string? PhoneNumber { get; set; }
}
}