Class FormInfo
- Namespace
- CMS.FormEngine
- Assembly
- CMS.FormEngine.dll
Ensures management of XML file that represents the form definition.
public class FormInfo : DataDefinition, IStructuredData
- Inheritance
-
objectFormInfo
- Implements
- Inherited Members
- Extension Methods
Constructors
FormInfo()
Empty constructor
public FormInfo()
FormInfo(string)
Constructor, creates the form info structure and loads specified form definition.
public FormInfo(string formDefinition)
Parameters
formDefinitionstringXML definition of the form
Methods
AddFormCategory(FormCategoryInfo, int)
Add a form category at the specified index or at the end if the index is not specified.
[Obsolete("Use AddFormItem(IDataDefinitionItem, int) instead.")]
public void AddFormCategory(FormCategoryInfo categObj, int index = -1)
Parameters
categObjFormCategoryInfoFormCategoryInfo object with data to add
indexintIndex to which to add the category
AddFormItem(IDataDefinitionItem, int)
Adds form item at the specified index or at the end if the index is not specified.
public void AddFormItem(IDataDefinitionItem formItem, int index = -1)
Parameters
formItemIDataDefinitionItemInserted form item
indexintIndex of newly inserted item
Clone()
Clones the object.
public FormInfo Clone()
Returns
CombineWithForm(FormInfo, CombineWithFormSettings)
Combines the form with another form info.
public void CombineWithForm(FormInfo newForm, CombineWithFormSettings settings)
Parameters
newFormFormInfoForm to include
settingsCombineWithFormSettingsCombine settings
CombineWithForm(FormInfo, bool, string, bool, bool)
Combines the form with another form info.
[Obsolete("Method is deprecated and will be removed in the next version. Use CombineWithForm(FormInfo, CombineWithFormSettings) instead.")]
public void CombineWithForm(FormInfo newForm, bool overwriteExisting, string excludeColumns = null, bool includeCategories = false, bool preserveCategory = true)
Parameters
newFormFormInfoForm to include
overwriteExistingboolIf true, existing fields from source form are overwritten by new form fields if their names match
excludeColumnsstringColumns to exclude from form combining, separated by semicolon (;)
includeCategoriesboolIf true, categories from the new form will be added
preserveCategoryboolIf false than even if overwriteExisting is false, field is moved to the current category (but the properties of the field are not overwritten)
EnsureDefaultValues(IDataContainer, FormResolveTypeEnum)
Ensures the default values into the data container.
[Obsolete("Method is deprecated and will be removed in the next version. Use LoadDefaultValues(IDataContainer, FormResolveTypeEnum, bool) instead.")]
public bool EnsureDefaultValues(IDataContainer container, FormResolveTypeEnum resolveType = FormResolveTypeEnum.None)
Parameters
containerIDataContainerContainer to load
resolveTypeFormResolveTypeEnumType of macro resolving
Returns
- bool
FieldExists(string)
Returns true if the given field exists in the form definition
public bool FieldExists(string fieldName)
Parameters
fieldNamestringField name to check
Returns
- bool
GetCategoryNames()
Returns an List of category names.
public List<string> GetCategoryNames()
Returns
- List<string>
GetColumnNames(bool, Func<FormFieldInfo, bool>)
Returns an List of field names.
public List<string> GetColumnNames(bool includeDummyFields = true, Func<FormFieldInfo, bool> order = null)
Parameters
includeDummyFieldsboolIndicates if dummy fields should be included.
orderFunc<FormFieldInfo, bool>Allows to order fields before names are returned.
Returns
- List<string>
GetEmptyFormDocument()
Gets empty root FormInfo XML node.
public static XmlDocument GetEmptyFormDocument()
Returns
- XmlDocument
GetFields(bool, bool, bool, bool, bool)
Returns an List of FormFieldInfo objects.
public List<FormFieldInfo> GetFields(bool visible, bool invisible, bool includeSystem = true, bool onlyPrimaryKeys = false, bool includeDummyFields = true)
Parameters
visibleboolIndicates whether object with visible set to 'True' should be returned
invisibleboolIndicates whether object with visible set to 'False' should be returned
includeSystemboolIndicates whether also system fields are included
onlyPrimaryKeysboolIndicates whether only primary keys should be returned
includeDummyFieldsboolIndicates whether dummy fields are included
Returns
- List<FormFieldInfo>
GetFields(string)
Returns the List of the FormFieldInfo objects.
public List<FormFieldInfo> GetFields(string fieldDataType)
Parameters
fieldDataTypestringForm field data type
Returns
- List<FormFieldInfo>
GetFormCategory(string)
Returns CategoryInfo object specified by category name.
public FormCategoryInfo GetFormCategory(string name)
Parameters
namestringCategory name
Returns
GetFormElements(bool, bool, bool)
Returns the List of the form elements.
public List<IDataDefinitionItem> GetFormElements(bool visible, bool invisible, bool hideSystemFields = false)
Parameters
visibleboolReturn visible fields
invisibleboolReturn invisible fields
hideSystemFieldsboolReturn non-system fields only
Returns
- List<IDataDefinitionItem>
GetFormField(Guid)
Returns field object with data from specified field.
public FormFieldInfo GetFormField(Guid guid)
Parameters
guidGuidForm field guid
Returns
- FormFieldInfo
Field or null if field does not exist
GetFormField(string)
Returns field object with data from specified field.
public FormFieldInfo GetFormField(string fieldName)
Parameters
fieldNamestringField to get data from
Returns
- FormFieldInfo
Field or null if field does not exist
GetFormSchema(string)
Returns SchemaInfo object specified by schema name.
public FormSchemaInfo GetFormSchema(string schemaName)
Parameters
schemaNamestringSchema name
Returns
Exceptions
- ArgumentException
Thrown when
schemaNameis null or empty.
GetXmlDefinition()
Returns FormInfo definition in XML.
public string GetXmlDefinition()
Returns
- string
GetXmlElement(XmlDocument)
Gets the XML element for the data
public override XmlElement GetXmlElement(XmlDocument doc)
Parameters
docXmlDocumentParent XML document
Returns
- XmlElement
LoadDefaultValues(IDataContainer, FormResolveTypeEnum, bool)
Loads the default values into the data container.
public void LoadDefaultValues(IDataContainer container, FormResolveTypeEnum resolveType = FormResolveTypeEnum.None, bool onlyVisible = false)
Parameters
containerIDataContainerContainer to load
resolveTypeFormResolveTypeEnumType of macro resolving
onlyVisibleboolIf set True data are loaded for visible fields only; default value is False
LoadItem(XmlNode)
Loads the item from the XML node
protected override IDataDefinitionItem LoadItem(XmlNode node)
Parameters
nodeXmlNodeXML node
Returns
MoveFormItem(int, int)
Moves form item in the form items collection from source index to destination index.
public void MoveFormItem(int sourceIndex, int destinationIndex)
Parameters
sourceIndexintIndex of the form item to be moved.
destinationIndexintIndex where to move the form item.
NewCategoryDefinition()
Creates a new category definition object.
protected virtual IDataDefinitionItem NewCategoryDefinition()
Returns
NewFieldDefinition()
Creates a new field definition object.
protected override IDataDefinitionItem NewFieldDefinition()
Returns
NewSchemaDefinition()
Creates a new schema definition object.
protected virtual IDataDefinitionItem NewSchemaDefinition()
Returns
RemoveEmptyCategories()
Removes all categories from the form that do not contain any fields
public void RemoveEmptyCategories()
RemoveFields(Func<FormFieldInfo, bool>)
Removes fields matching the given condition
public bool RemoveFields(Func<FormFieldInfo, bool> condition)
Parameters
conditionFunc<FormFieldInfo, bool>Field condition
Returns
- bool
Returns true if at least one item was removed
RemoveFormCategory(string)
Remove specified form category.
public void RemoveFormCategory(string categoryName)
Parameters
categoryNamestringName of a category to remove
RemoveFormField(string)
Removes specified form field.
public bool RemoveFormField(string fieldName)
Parameters
fieldNamestringName of a field to remove
Returns
- bool
True if successfully removed, false otherwise
RemoveFormSchema(string)
Remove specified form schema.
public void RemoveFormSchema(string schemaName)
Parameters
schemaNamestringName of a schema to remove.
Exceptions
- ArgumentException
Thrown when
schemaNameis null or empty.- InvalidOperationException
Thrown when no schema with
schemaNamename was found.
UpdateFormCategory(string, FormCategoryInfo)
Update specified category node.
public void UpdateFormCategory(string categoryName, FormCategoryInfo fci)
Parameters
categoryNamestringName of category to update
fciFormCategoryInfoFormCategoryInfo object with data for update
UpdateFormField(string, FormFieldInfo)
Update specified field node.
public void UpdateFormField(string fieldName, FormFieldInfo field)
Parameters
fieldNamestringName of a field to update
fieldFormFieldInfoData for update
Exceptions
- ArgumentOutOfRangeException
Field fieldName does not exist
UpdateFormSchema(string, FormSchemaInfo)
Update specified schema node.
public void UpdateFormSchema(string schemaName, FormSchemaInfo formSchemaInfo)
Parameters
schemaNamestringName of schema to update.
formSchemaInfoFormSchemaInfoFormSchemaInfo object with data for update.
Exceptions
- ArgumentException
Thrown when
schemaNameis null or empty.- ArgumentNullException
Thrown when
formSchemaInfois null.- InvalidOperationException
Thrown when no schema with
schemaNamename was found.