Show hint in a form template

1 Answer 340 Views
Form
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Martin Herløv asked on 24 Jan 2023, 03:21 PM
How can I show a hint when using a formtemplate? I am using code code like this validation messages for templated Form items But are missing the Hint for a consistent layout.

Also why not add change events to the FormItem

1 Answer, 1 is accepted

Sort by
0
Yanislav
Telerik team
answered on 27 Jan 2023, 11:20 AM

Hello Martin,

Let me address your questions below:

How to include Hint when a Template is used.

On one hand, the Hint attribute relies on our built-in rendering. On the other hand, the FormItem <Template> allows full customization of the rendering. As a result, the two properties are mutually exclusive. So if you want to include a hint you have to add it in the template: 

        <FormItem...>
            <Template>
...
                <div class="k-form-hint" >Enter your first name</div>
                <TelerikValidationMessage For="@(() => MyModel.FirstName)" />
            </Template>
        </FormItem>
OnChange event to a <FormItem> tag in an autogenerated form

The <FormItem> tag does not expose an OnChange event that you may handle. You may instead use a FormItem Template, render the appropriate editor and subscribe to its OnChange.

For example, if the "First Name" field is a string, you may render a Textbox component and handle its OnChange to perform the name check.

Side note:

The OnUpdate event for the Form can be suitable if you want to track the changes in the fields. It may be useful for your scenario as this event will fire after a change in any of the editors. It provides the field name from which the change was triggered.

I hope this information helps. 

Regards,
Yanislav
Progress Telerik

Learn about the important changes coming in UI for Blazor 4.0 in January 2023!
Tags
Form
Asked by
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Yanislav
Telerik team
Share this question
or