Skip to content

Commit 30b9837

Browse files
Form input (WIP, unstable)
1 parent 1e900e8 commit 30b9837

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

src/Blazor.AdminLte.Site.Shared/Pages/Forms/General.razor

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
11
@page "/forms/general"
22
<ContentHeader>
33
<Header>
4-
<PageTitle Title="General Forms" />
4+
<PageTitle Title="General Form" />
55
</Header>
66
</ContentHeader>
77
<ContentMain>
8+
<Row>
9+
<Column Classes="col.md._6">
10+
<Card HeaderBackgroundColor="Color.Primary" ToolOptions="new CardToolOptions { Collapsable = true, Maximizable=true}">
11+
<Title><CardTitle>Quick Example</CardTitle></Title>
12+
<Header><CardTools /></Header>
13+
<Body>
14+
<FormGroup>
15+
@code{
16+
List<InputState> Inputs = new List<InputState>()
17+
{
18+
new InputState(){Identifier="exampleInputEmail1", Placeholder="Enter email", Label="Email Address", Type="email"},
19+
new InputState(){Identifier="exampleInputPassword1", Placeholder="Password", Label="Password", Type="password"},
20+
new InputState(){Identifier="exampleInputFile1", Placeholder="Choose file", Label="Email Address", Type="file"}
21+
};
22+
}
23+
@for (int i = 0; i < Inputs.Count; i++)
24+
{
25+
<Input @bind-Value="Inputs[i]" /> <text>Value: @Inputs[i].Value;</text>
26+
@System.Text.Json.JsonSerializer.Serialize(Inputs[i]);
27+
}
28+
</FormGroup>
29+
</Body>
30+
<Footer>
31+
<Button>Submit</Button>
32+
</Footer>
33+
</Card>
34+
</Column>
35+
</Row>
36+
837
<Card>
938
<Title><CardTitle>Some simple link content</CardTitle></Title>
1039
<Body>
1140
<FormGroup>
1241
@code{
1342
List<CustomCheckboxState> Checkboxes = new List<CustomCheckboxState>()
14-
{
43+
{
1544
new CustomCheckboxState(){ Identifier = "customCheckbox1", Value="option1", Label="Custom Checkbox"},
1645
new CustomCheckboxState(){ Identifier = "customCheckbox2", Value="option2", IsChecked=true, Label= "Custom Checkbox checked"},
1746
new CustomCheckboxState(){ Identifier = "customCheckbox3", Value="option3", IsDisabled=true, Label= "Custom Checkbox disabled"}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@namespace Blazor.AdminLte
2+
<label for="@Value.Identifier">@((MarkupString)Value.Label)</label>
3+
<input class="form-control" id="@Value.Identifier" placeholder="@Value.Placeholder" value="@Value.Value" @onchange="DoChange" type="@Value.Type">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace Blazor.AdminLte
4+
{
5+
public partial class Input
6+
{
7+
[Parameter]
8+
public InputState Value { get; set; }
9+
10+
[Parameter]
11+
public EventCallback<InputState> ValueChanged { get; set; }
12+
13+
[Parameter]
14+
public EventCallback<InputState> OnChange { get; set; }
15+
16+
private void DoChange(ChangeEventArgs e)
17+
{
18+
Value.Value = (string)e.Value;
19+
ValueChanged.InvokeAsync(Value);
20+
if (OnChange.HasDelegate)
21+
OnChange.InvokeAsync(Value);
22+
}
23+
}
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Blazor.AdminLte
2+
{
3+
public class InputState
4+
{
5+
public string Value { get; set; }
6+
public string Identifier { get; set; }
7+
public string Label { get; set; }
8+
public string Placeholder { get; set; }
9+
public string Type { get; set; }
10+
11+
}
12+
}

0 commit comments

Comments
 (0)