Skip to content

Commit 044a43c

Browse files
authored
kb(Validation): Enhance ValueExpression syntax information
1 parent 7210c8b commit 044a43c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

knowledge-base/inputs-validation-child-component.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ page_title: Validate a Telerik component as child component and apply invalid bo
66
slug: inputs-kb-validate-child-component
77
position:
88
tags: telerik, blazor, form, validation
9-
ticketid: 1499665
9+
ticketid: 1499665, 1697034
1010
res_type: kb
1111
---
1212

@@ -39,9 +39,9 @@ I am wrapping a Telerik component inside a custom component in my Form. When I t
3939

4040
Internally, the Telerik input components use the cascading `EditContext` parameter that the `EditForm` and `TelerikForm` provide. The `EditContext` API allow the components to determine if validation has passed or failed. If the validation fails, the components show a red border.
4141

42-
When you wrap an input component in another component, you must define a `ValueExpression` parameter in the custom component. This will allow the custom component to receive the correct expression from the parent component, which holds the Form. The Blazor framework generates the expression automatically when using `@bind-Value`, but not when there is another component in the component hierarchy tree.
42+
When you wrap an input component in a custom child component, you must define a `ValueExpression` parameter for the child component. This allows the child component to receive the correct expression from the parent component, which holds the Form. The Blazor framework generates the expression automatically when using `@bind-Value`, but not when there is another component in the component hierarchy tree.
4343

44-
The example below shows how to wrap a Telerik TextBox and DropDownList in different `.razor` files and get the invalid red border when the validation does not pass.
44+
The example below shows how to wrap a Telerik TextBox and DropDownList in different `.razor` files and get the invalid red border when the validation does not pass. Note the different `For` parameter syntax in the two `<TelerikValidationMessage />` instances in `Home.razor` and `DropDownList.razor`. The `For` syntax depends on whether the `TelerikValidationMessage` component is in the same component as the Form, or in a child component, which consumes a `ValueExpression` parameter.
4545

4646
>caption Validate a TextBox and a DropDownList in custom components with ValueExpression parameters
4747
@@ -63,6 +63,7 @@ The example below shows how to wrap a Telerik TextBox and DropDownList in differ
6363
<div class="k-form-field-wrap">
6464
<TextBox @bind-Value="@CustomerToEdit.Name"
6565
Id="customer-name" />
66+
<TelerikValidationMessage For="@(() => CustomerToEdit.Name)" />
6667
</div>
6768
</Template>
6869
</FormItem>
@@ -75,6 +76,7 @@ The example below shows how to wrap a Telerik TextBox and DropDownList in differ
7576
TextField="@nameof(Country.Name)"
7677
ValueField="@nameof(Country.Id)"
7778
Id="customer-countryid" />
79+
@* TelerikValidationMessage is in DropDownList.razor *@
7880
</div>
7981
</Template>
8082
</FormItem>
@@ -154,6 +156,7 @@ The example below shows how to wrap a Telerik TextBox and DropDownList in differ
154156
TextField="@TextField"
155157
ValueField="@ValueField"
156158
Id="@Id" />
159+
<TelerikValidationMessage For="@ValueExpression" />
157160
158161
@code {
159162
[Parameter]

0 commit comments

Comments
 (0)