Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor pass ValidationMessage to extended InputText component

$
0
0

I have an ExtendedInputText component which inherits from InputText

@inherits InputText<div class="flex"><label class="w-1/2">        @Label         @if(Required){<span class="text-red-500 ml-1">*</span>        }</label><InputText        class="flex-1 border border-gray-200 bg-white p-2 rounded"        placeholder="@Label"        Value="@Value"        ValueChanged="@ValueChanged"        ValueExpression="@ValueExpression"        Required="@Required"    /></div>@code{    [Parameter]    public bool Required { get; set; }    [Parameter]    public string Label { get; set; }}

I intend on using it to replace this

<EditForm Model="Command" OnValidSubmit="OnValidSubmit"><FluentValidationValidator /><ValidationSummary /><div class=""><label>Title <span class="text-red-500">*</span></label><InputText id="Title" @bind-Value="Command.Title" /><ValidationMessage For="@(() => Command.Title)" /></div><button type="submit" class="p-2 bg-positive-500 text-white rounded">Create</button></EditForm>

with this

<EditForm Model="Command" OnValidSubmit="OnValidSubmit"><FluentValidationValidator /><ValidationSummary /><ExtendedInputText Label="Title" Required="true" @bind-Value="Command.Title"/><button type="submit" class="p-2 bg-positive-500 text-white rounded">Create</button></EditForm>

How would I go about also passing <ValidationMessage For="@(() => Command.Title)" /> to the ExtendedInputText component and rendering it from within?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>