Table of Contents

Class FormComponent<TProperties, TClientProperties, TValue>

Namespace
Kentico.Xperience.Admin.Base.Forms
Assembly
Kentico.Xperience.Admin.Base.dll

Represents a base class for UI form component containing members used by the system.

public abstract class FormComponent<TProperties, TClientProperties, TValue> : IFormComponent, IFormItem<IFormComponentClientProperties>, IFormItem where TProperties : FormComponentProperties, new() where TClientProperties : FormComponentClientProperties<TValue>, new()

Type Parameters

TProperties
TClientProperties
TValue
Inheritance
object
FormComponent<TProperties, TClientProperties, TValue>
Implements
Derived
FormComponent<TClientProperties, TValue>
Extension Methods

Constructors

FormComponent()

Initializes a new instance of the FormComponent<TClientProperties, TValue> class for the specified properties type.

protected FormComponent()

FormComponent(ILocalizationService)

Initializes a new instance. Use this constructor directly only for testing purposes.

protected FormComponent(ILocalizationService localizationService)

Parameters

localizationService ILocalizationService

Properties

AdditionalActions

Gets the list of additional actions associated with the form component.

public IList<IAdditionalAction> AdditionalActions { get; }

Property Value

IList<IAdditionalAction>
See Also

ClientComponentName

Name of the front-end type implementing the UI form component.

public abstract string ClientComponentName { get; }

Property Value

string

FormContext

Context of the form where the component is used.

public IFormContext FormContext { get; }

Property Value

IFormContext

Guid

Gets or sets the underlying field GUID.

public Guid Guid { get; }

Property Value

Guid

HasDependencies

Gets or sets the value indicating whether evaluation of a visibility condition of some other component depends on this component's value.

public bool HasDependencies { get; }

Property Value

bool

Name

Gets the underlying field name.

public string Name { get; }

Property Value

string

Properties

Gets the server component properties.

public TProperties Properties { get; init; }

Property Value

TProperties

Required

Gets or sets value indicating whether the underlying field is required. False by default. If false, the form component's implementation must accept nullable input.

public bool Required { get; }

Property Value

bool

ValidationRules

Gets the list of validation rules associated with the form component.

public IList<IValidationRule> ValidationRules { get; }

Property Value

IList<IValidationRule>
See Also

VisibilityConditions

Gets the list of visibility conditions associated with the form component.

public IList<IVisibilityCondition> VisibilityConditions { get; }

Property Value

IList<IVisibilityCondition>
See Also

Methods

AddAdditionalAction(IAdditionalAction)

Adds a new additional action.

public virtual void AddAdditionalAction(IAdditionalAction additionalAction)

Parameters

additionalAction IAdditionalAction

Additional action to be added.

Exceptions

ArgumentNullException

Thrown when additionalAction is null.

InvalidOperationException

Thrown when there is already another additional action with the same Identifier.

AddValidationRule(IValidationRule)

Adds a new validation rule.

public virtual void AddValidationRule(IValidationRule validationRule)

Parameters

validationRule IValidationRule

Validation rule to be added.

Exceptions

ArgumentNullException

Thrown when validationRule is null.

AddVisibilityCondition(IVisibilityCondition)

Adds a new visibility condition.

public virtual void AddVisibilityCondition(IVisibilityCondition visibilityCondition)

Parameters

visibilityCondition IVisibilityCondition

Visibility condition to be added.

Exceptions

ArgumentNullException

Thrown when visibilityCondition is null.

BindContext(IFormContext)

Binds context to the form component.

public virtual Task BindContext(IFormContext context)

Parameters

context IFormContext

Context to be used.

Returns

Task

Remarks

This method is called later than ConfigureComponent() method.

ConfigureClientProperties(TClientProperties)

Configures the form component client properties.

protected virtual Task ConfigureClientProperties(TClientProperties clientProperties)

Parameters

clientProperties TClientProperties

The current instance of the form component client properties.

Returns

Task

Remarks

Override this method in order to configure form component client properties.

ConfigureComponent()

Configures the form component. This method is called when all form component properties are set.

protected virtual void ConfigureComponent()

Remarks

Override this method to set component inner state, like additional component validation rules.

GetClientProperties()

public Task<IFormComponentClientProperties> GetClientProperties()

Returns

Task<IFormComponentClientProperties>

GetValue()

Gets the value of the form component.

public virtual TValue GetValue()

Returns

TValue

Returns the value of the form component.

Remarks

The value can be additionally modified before it is retrieved for data propagation.

ResponseFrom<TResult>(TResult)

Returns a form component command response from the passed result.

protected ICommandResponse<TResult> ResponseFrom<TResult>(TResult result)

Parameters

result TResult

Result of the command processed on the client template.

Returns

ICommandResponse<TResult>

Type Parameters

TResult

Type of the returned result.

Remarks

The result is passed to the command after handler.

SetValue(TValue)

Sets the value of the form component.

public virtual void SetValue(TValue value)

Parameters

value TValue

Value to be set.

Remarks

The value can be additionally modified for component usage. Component is fully configured when method is called.