mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-12 11:55:24 +08:00
refactor(module: form): make validate mode default to Complex (#4163)
This commit is contained in:
parent
4459d3ea8c
commit
063c24c8a9
@ -19,10 +19,14 @@
|
||||
{
|
||||
<FormRulesValidator @ref="_rulesValidator" />
|
||||
}
|
||||
else
|
||||
else if (Validate != null)
|
||||
{
|
||||
@Validator
|
||||
}
|
||||
else
|
||||
{
|
||||
<DataAnnotationsValidator />
|
||||
}
|
||||
<CascadingValue Value="this" Name="Form" TValue="IForm" IsFixed="@true">
|
||||
@if (!string.IsNullOrEmpty(Size))
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ namespace AntDesign
|
||||
/// Validator to use in the form. Used when <see cref="ValidateMode"/> is <c>FormValidateMode.Default</c> or <c>FormValidateMode.Complex</c>
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment Validator { get; set; } = _defaultValidator;
|
||||
public RenderFragment Validator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable validation when component values change
|
||||
@ -213,15 +213,10 @@ namespace AntDesign
|
||||
/// <summary>
|
||||
/// Which mode of validation the form should use
|
||||
/// </summary>
|
||||
/// <default value="FormValidateMode.Default"/>
|
||||
/// <default value="FormValidateMode.Complex"/>
|
||||
[Parameter]
|
||||
public FormValidateMode ValidateMode { get; set; } = FormValidateMode.Default;
|
||||
|
||||
private static readonly RenderFragment _defaultValidator = builder =>
|
||||
{
|
||||
builder.OpenComponent<DataAnnotationsValidator>(0);
|
||||
builder.CloseComponent();
|
||||
};
|
||||
[Obsolete("Will use both attributes and rules in the same time.")]
|
||||
public FormValidateMode ValidateMode { get; set; } = FormValidateMode.Complex;
|
||||
|
||||
/// <summary>
|
||||
/// If enabled, form submission is performed without fully reloading the page. This is equivalent to adding data-enhance to the form.
|
||||
@ -494,7 +489,7 @@ namespace AntDesign
|
||||
|
||||
bool IForm.UseLocaleValidateMessage => UseLocaleValidateMessage;
|
||||
|
||||
private bool UseRulesValidator => UseLocaleValidateMessage || ValidateMode != FormValidateMode.Default;
|
||||
private bool UseRulesValidator => UseLocaleValidateMessage && Validator == null;
|
||||
|
||||
private void BuildEditContext()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user