Class FormProvider
Contains methods for forms and their fields retrieval.
public class FormProvider : IFormProvider
- Inheritance
-
objectFormProvider
- Implements
- Extension Methods
Constructors
FormProvider(IFormComponentDefinitionProvider, IFormComponentActivator, IFormComponentPropertiesMapper)
Initializes a new instance of the FormProvider class.
public FormProvider(IFormComponentDefinitionProvider formComponentDefinitionProvider, IFormComponentActivator formComponentActivator, IFormComponentPropertiesMapper formComponentPropertiesMapper)
Parameters
formComponentDefinitionProviderIFormComponentDefinitionProviderProvider for registered form components retrieval.
formComponentActivatorIFormComponentActivatorActivator for form components.
formComponentPropertiesMapperIFormComponentPropertiesMapperMapper for form component properties.
Methods
CreateFormComponent(FormFieldInfo, BizFormComponentContext)
Creates a new form component instance based on its description in the form field.
protected virtual FormComponent CreateFormComponent(FormFieldInfo formFieldInfo, BizFormComponentContext context)
Parameters
formFieldInfoFormFieldInfoForm field describing the form component to create.
contextBizFormComponentContextContextual information specifying where the form component is being used.
Returns
- FormComponent
Returns an instance of the form component as described in the form field.
Remarks
A component instance is created using the Kentico.Forms.Web.Mvc.FormComponentActivator and IFormComponentPropertiesMapper passed when initializing this provider. A proper Name is filled in the created component and SetObjectValue(object) method is called to set default value.
GetFormComponents(BizFormInfo, BizFormComponentContext)
Gets a list of form components which represent the model to be rendered in a view.
public virtual List<FormComponent> GetFormComponents(BizFormInfo bizFormInfo, BizFormComponentContext bizFormComponentContext = null)
Parameters
bizFormInfoBizFormInfoBiz form for which to return a list of corresponding form components.
bizFormComponentContextBizFormComponentContextBiz form component context, which is set in created components. If FormInfo is null, it is set to
bizFormInfo.
Returns
- List<FormComponent>
Returns a list of form components.
Exceptions
- ArgumentNullException
Thrown when
bizFormInfois null.
GetFormInfo(BizFormInfo)
Gets FormInfo for the specified bizFormInfo.
protected virtual FormInfo GetFormInfo(BizFormInfo bizFormInfo)
Parameters
bizFormInfoBizFormInfoForm to return FormInfo for.
Returns
Remarks
Returned instance of FormInfo should not be modified as it is cached within FormHelper.
Exceptions
- ArgumentNullException
Thrown when
bizFormInfois null.
SetBizFormItemData(BizFormItem, List<FormComponent>)
Sets data from visibleFormComponents to given formItem.
protected virtual void SetBizFormItemData(BizFormItem formItem, List<FormComponent> visibleFormComponents)
Parameters
formItemBizFormItemForm item to which data is set.
visibleFormComponentsList<FormComponent>Collection of visible form components from which to set data inside
formItem.
SetContact(FormInfo, BizFormItem, Guid)
Sets the current contact identifier to given item.
protected void SetContact(FormInfo formInfo, BizFormItem item, Guid contactGuid)
Parameters
formInfoFormInfoitemBizFormItemcontactGuidGuid
SetFormData(BizFormInfo, List<FormComponent>, Guid?)
Sets data of a form represented by a list of its components.
public virtual BizFormItem SetFormData(BizFormInfo bizFormInfo, List<FormComponent> formComponents, Guid? contactGuid)
Parameters
bizFormInfoBizFormInfoBiz form whose data are to be set.
formComponentsList<FormComponent>Form components containing values to be set.
contactGuidGuid?Guid of current contact, can be null.
Returns
- BizFormItem
Returns the biz form item set.
Remarks
The SaveBizFormItem event is invoked on all form components which have been initialized using an instance of BizFormComponentContext.
Exceptions
- ArgumentNullException
Thrown when
bizFormInfoorformComponentsis null.
UpdateFormData(BizFormInfo, int, List<FormComponent>, Guid?)
Updates form data of already existing BizFormItem.
public virtual BizFormItem UpdateFormData(BizFormInfo bizFormInfo, int bizFormItemId, List<FormComponent> formComponents, Guid? contactGuid)
Parameters
bizFormInfoBizFormInfoForm to be updated.
bizFormItemIdintIdentifier of form record to be updated.
formComponentsList<FormComponent>Form components containing values to be set.
contactGuidGuid?Guid of current contact, can be null.
Returns
- BizFormItem
Returns the updated biz form item.
Remarks
The SaveBizFormItem event is invoked on all form components which have been initialized using an instance of BizFormComponentContext.
Exceptions
- ArgumentNullException
Thrown when
bizFormInfoorformComponentsis null.- ArgumentOutOfRangeException
Thrown when
bizFormItemIddoes not specify an existing BizFormItem.