We are creating a custom control which contains a kendo textbox. (The custom control only contains the kendo-textbox) We want to use reactive forms with the formGroup/formControlName in this custom control on the kendo-textbox
How can I achieve this one?
thanks!
Preslava
Telerik team
commented on 25 May 2021, 06:12 AM
Hi Kristof,
Indeed, the TextBox can be used in a reactive form.
Please, check the following example, which demonstrates the desired form:
This is our setup:
A page (Angular component) contains a '<custom-textbox>' (Angular component)
The custom-textbox component contains the <kendo-ui textbox> component.
The page has a <form> using the reactive forms and the custom-textbox need to set the formControl(Name) on the underlying kendo-ui textbox.
At this moment i created an input-property on the custom-textbox of type FormControl, which is bound to the 'formControl' property on the kendo-ui textbox.
Hi Kristof,
Indeed, the TextBox can be used in a reactive form.
Please, check the following example, which demonstrates the desired form:
https://stackblitz.com/edit/angular-qnvxtu-nc3ccx?file=app/app.component.ts
The example above also showcases how to set validators and validation icons, if such are needed.
More information and another demo could be found here:
https://www.telerik.com/kendo-angular-ui/components/inputs/textbox/forms/#toc-reactive-forms
Let me know, if this information helps.
This is our setup:
A page (Angular component) contains a '<custom-textbox>' (Angular component)
The custom-textbox component contains the <kendo-ui textbox> component.
The page has a <form> using the reactive forms and the custom-textbox need to set the formControl(Name) on the underlying kendo-ui textbox.
At this moment i created an input-property on the custom-textbox of type FormControl, which is bound to the 'formControl' property on the kendo-ui textbox.
I was wondering if this is the right way to do.
Hi Kristof,
Yes, this seems correct.