Checkbox - working example -- NumberInput,TextInput - InputAttributes initialization moved to InputBase class #8
@ -6,12 +6,13 @@
 | 
			
		||||
 | 
			
		||||
<p>SelectedValue: @SelectedValue.ToString()</p>
 | 
			
		||||
 | 
			
		||||
<SimpleSelect
 | 
			
		||||
    Items="@items" 
 | 
			
		||||
    Label="Simple select" 
 | 
			
		||||
    @bind-Value=@SelectedValue
 | 
			
		||||
/>
 | 
			
		||||
 | 
			
		||||
<CheckBoxGroup Id="chkgroup1">
 | 
			
		||||
    <CheckBox Id="checkbox1" Label="Chk 1" />
 | 
			
		||||
    <CheckBox Id="checkbox2" Label="Chk 2" />
 | 
			
		||||
    <CheckBox Id="checkbox3" Label="Chk 3" />
 | 
			
		||||
    <CheckBox Id="checkbox4" Label="Chk 4" />
 | 
			
		||||
    <CheckBox Id="checkbox5" Label="Chk 5" />
 | 
			
		||||
</CheckBoxGroup>
 | 
			
		||||
 | 
			
		||||
@code {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -76,13 +76,18 @@ public partial class SimpleSelect<ValueType> : InputBase
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnParametersSetAsync()
 | 
			
		||||
	{
 | 
			
		||||
		if (base.InputAttributes is null) base.InputAttributes = new();
 | 
			
		||||
		if (base.Required)
 | 
			
		||||
		{
 | 
			
		||||
			if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		OriginalItems = Items;
 | 
			
		||||
		if (_searchText.Length>0) await FilterItems();
 | 
			
		||||
		await base.OnParametersSetAsync();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected override async Task OnInitializedAsync()
 | 
			
		||||
	{
 | 
			
		||||
		await base.OnInitializedAsync();
 | 
			
		||||
		if (Required)
 | 
			
		||||
		{
 | 
			
		||||
			if (InputAttributes.ContainsKey("required")) InputAttributes.Add("required", true);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user