Class FormTemplate
Represents a template component within the SfDataForm that allows custom content or components to be used for rendering form items.
Inheritance
Namespace: Syncfusion.Blazor.DataForm
Assembly: Syncfusion.Blazor.dll
Syntax
public class FormTemplate : OwningComponentBase
Remarks
This component provides the flexibility to inject custom HTML or Blazor components as part of a form. You can use the ChildContent property to supply your own layout and logic.
Examples
The following example demonstrates how to use a FormTemplate
to provide a custom UI for a field inside SfDataForm:
<SfDataForm Model="SampleModel">
<FormItems>
<FormItem Field="@nameof(SampleModel.FieldValue)">
<Template>
<div class="my-template">
<label for="nameId">Custom Label:</label>
<input type="text" id="nameId" @bind-value="@SampleModel.FieldValue" />
</div>
</Template>
</FormItem>
</FormItems>
</SfDataForm>
Constructors
FormTemplate()
Declaration
public FormTemplate()
Properties
ChildContent
Gets or sets the content to be rendered inside the FormTemplate within SfDataForm.
Declaration
public RenderFragment ChildContent { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment | A Microsoft.AspNetCore.Components.RenderFragment specifying the custom components or markup to display within the form template. The default value is |
Remarks
Use this property to define custom elements, layouts, or logic rendered as part of the SfDataForm layout. This template may include HTML or other Blazor components suited to your scenario.
Examples
The following demonstrates providing a custom section inside a form template:
<Template>
<MyCustomEditor Data="@context.FieldValue"/>
</Template>
Methods
Dispose()
Releases unmanaged resources used by the FormTemplate component.
Declaration
public virtual void Dispose()
Remarks
This method should be called to dispose of the template resources and references held by this instance when it is no longer needed.
Examples
var template = new FormTemplate();
template.Dispose();
Dispose(Boolean)
Releases unmanaged resources used by the FormTemplate component and, optionally, managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | A |
Remarks
Call this method with disposing
set to true
to dispose both managed and unmanaged resources.
When disposing
is false
, only unmanaged resources are released.
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |