Class RadzenTemplateForm<TItem>
A component which represents a form
. Provides validation support.
[CascadingTypeParameter("TItem")]
public class RadzenTemplateForm<TItem> : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenForm
Type Parameters
TItem
- Inheritance
-
RadzenTemplateForm<TItem>
- Implements
- Inherited Members
Examples
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string Email { get; set; }
}
Model model = new Model();
}
Constructors
RadzenTemplateForm()
Initializes a new instance of the RadzenTemplateForm<TItem> class.
public RadzenTemplateForm()
Properties
Action
Specifies the form action
attribute. When set the form submits to the specified URL.
[Parameter]
public string Action { get; set; }
Property Value
Examples
<RadzenTemplateForm TItem="Model" Method="post" Action="/register" Data=@model>
<RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
ChildContent
Gets or sets the child content.
[Parameter]
public RenderFragment<EditContext> ChildContent { get; set; }
Property Value
Data
Specifies the model of the form. Required to support validation.
[Parameter]
public TItem Data { get; set; }
Property Value
- TItem
EditContext
Gets or sets the edit context.
[Parameter]
public EditContext EditContext { get; set; }
Property Value
- EditContext
The edit context.
InvalidSubmit
A callback that will be invoked when the user submits the form and IsValid is false
.
[Parameter]
public EventCallback<FormInvalidSubmitEventArgs> InvalidSubmit { get; set; }
Property Value
Examples
<RadzenTemplateForm TItem="Model" InvalidSubmit=@OnInvalidSubmit Data=@model>
<RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string Email { get; set; }
}
Model model = new Model();
void OnInvalidSubmit(FormInvalidSubmitEventArgs args)
{
}
}
IsValid
Returns the validity of the form.
public bool IsValid { get; }
Property Value
- bool
true
if all validators in the form a valid; otherwise,false
.
Method
Specifies the form method
attribute. Used together with Action.
[Parameter]
public string Method { get; set; }
Property Value
Examples
<RadzenTemplateForm TItem="Model" Method="post" Action="/register" Data=@model>
<RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
OnInvalidSubmit
Obsolete. Use InvalidSubmit instead.
[Parameter]
[Obsolete]
public EventCallback<FormInvalidSubmitEventArgs> OnInvalidSubmit { get; set; }
Property Value
Submit
A callback that will be invoked when the user submits the form and IsValid is true
.
[Parameter]
public EventCallback<TItem> Submit { get; set; }
Property Value
- EventCallback<TItem>
Examples
<RadzenTemplateForm TItem="Model" Submit=@OnSubmit Data=@model>
<RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string Email { get; set; }
}
Model model = new Model();
void OnSubmit(Model value)
{
}
}
Methods
AddComponent(IRadzenFormComponent)
public void AddComponent(IRadzenFormComponent component)
Parameters
component
IRadzenFormComponent
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
builder
RenderTreeBuilder
FindComponent(string)
public IRadzenFormComponent FindComponent(string name)
Parameters
name
string
Returns
GetComponentCssClass()
protected override string GetComponentCssClass()
Returns
OnParametersSet()
protected override void OnParametersSet()
OnSubmit()
Handles the submit event of the form.
protected Task OnSubmit()
Returns
RemoveComponent(IRadzenFormComponent)
public void RemoveComponent(IRadzenFormComponent component)
Parameters
component
IRadzenFormComponent