Hello,
We are using Telerik UI for ASP.NET Core and have run into a limitation with the kendo-form tag helper. We would appreciate your guidance on how to resolve or work around it.
The Scenario
We have a form that operates in two modes—Create and Edit—using two different models. To avoid duplicating markup, we want to share the form field structure between both modes while dynamically switching the underlying data/model.
What We Tried
We extracted the <form-items> content into a shared partial view and attempted to include it inside the <kendo-form> tag helper using @await Html.PartialAsync("_FormFieldsPartial").
@if (Model.IsCreateMode)
{
<kendo-form name="clientForm" form-data="Model.CreateData" method="post">
@await Html.PartialAsync("_ApiClientFormFields")
<validatable validation-summary="true" />
<buttons-template>
<button type="submit" class="k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary">Create</button>
<a href="/WebAPICredentials" class="k-button k-button-md k-rounded-md k-button-flat k-button-flat-base">Cancel</a>
</buttons-template>
</kendo-form>
}
else
{
<kendo-form name="clientForm" form-data="Model.EditData" method="post">
@await Html.PartialAsync("_ApiClientFormFields")
<validatable validation-summary="true" />
<buttons-template>
<button type="submit" class="k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary">Save</button>
<a href="/WebAPICredentials" class="k-button k-button-md k-rounded-md k-button-flat k-button-flat-base">Cancel</a>
</buttons-template>
</kendo-form>
}
What We Observed
- Observation 1 (Full Form): When the partial view contained the full form (11 fields using various editor tag helpers like textbox-editor, switch-editor, etc.), all 11 labels rendered on the page, but no input fields or widgets appeared.
- Observation 2 (Stripped-Down Form): When we stripped the partial view down to just 5 basic fields using only textbox-editor, all 11 labels still rendered on the page, despite only 5 fields being defined in the partial.
Our Question
Is there a supported way to share <form-items> content across multiple <kendo-form> instances using partial views, or is this a known limitation of how the tag helper parses its child content?
If partial views are not supported for this use case, what alternative approach do you recommend to avoid duplicating 11+ fields across our Create and Edit views?
Thank you for your help.
Hi Alfonzo,
The <kendo-form> TagHelper does not support rendering <form-items> via partial views (e.g., using @await Html.PartialAsync). The TagHelper parses its child content at compile time, while partial views are rendered at runtime. Because of this, the TagHelper cannot recognize <form-items> or their children when they come from a partial view.
If you need to use different models in the Form, you can consider using the Kendo UI for jQuery form and use the setOptions method to change the rendered fields dynamically:
- https://www.telerik.com/kendo-jquery-ui/documentation/api/javascript/ui/form/methods/setoptions
Here is such a basic example: https://dojo.telerik.com/sePgtNvz/2
I hope this helps.
Neli
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.