Required field indicator for FormItems

1 Answer 51 Views
Form
Kevin
Top achievements
Rank 1
Kevin asked on 14 Aug 2024, 08:47 PM

Looking to leverage the Required data annotation on the model to apply an asterisk or other required field indicator to a FormItem's label. Is there a way to apply an html attribute/class to a FormItem automatically, that could then be used to append an asterisk to its label? Trying to avoid the need of marking Required both in the model and the UI.

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimo
Telerik team
answered on 15 Aug 2024, 02:10 PM

Hello Kevin,

As a UI component vendor we focus on the UI. On the other hand, there can be a lot of different ways to signify a required field. Although the asterisk is a common approach, it is by no means universally accepted or understandable. Every customer may even want the asterisk to look differently. That's why we have decided not to provide such automatic UI out-of-the-box.

So, you are right that you need to either define (hard-code) the required items in the UI or use reflection to get the DataAnnotations attributes for each Field and then append asterisks to the FormItem LabelText parameter or in the FormItem Template.

Regards,
Dimo
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

Tags
Form
Asked by
Kevin
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or