1. Sitecore Forms

Base interface and classes for creating value providers

Version:

When you create a value provider, you must create a class that inherits the IFieldValueProvider interface. This interface contains the GetValue method that you must implement in your new class.

  • Interface or method: Description
  • Interface for providing field values:
public interface IFieldValueProvider
{FieldValueProviderContext ValueProviderContext { get; set; }

object GetValue(string parameters);
 }
  • Context for executing value providers:
public class FieldValueProviderContext
{
 public Database Database { get; set; }
 public Item FieldItem { get; set; }
 }
  • Method in the IValueField interface for field value initialization:
public interface IValueField
 {
 

 void InitializeValue(FieldValueProviderContext context);
 }
  • Virtual method in InputViewModel<TValueType> which is overridden in derived classes and casts the value supplied by the provider to the specified TValueType:
public class InputViewModel<TValueType>
 {
 

 protected virtual void InitializeValue(object value)
 {
 if (value != null)
 {
 Value = (TValueType)value;
 }
 }
 }
If you have suggestions for improving this article, let us know!