Class FormHelper
- Namespace
- CMS.FormEngine
- Assembly
- CMS.FormEngine.dll
Class providing form helper methods.
public static class FormHelper
- Inheritance
-
objectFormHelper
Fields
BIZ_FORM_FILES_FOLDER_NAME
Name of the folder where BizForm files are stored.
public const string BIZ_FORM_FILES_FOLDER_NAME = "BizFormFiles"
Field Value
- string
FORM_PREFIX
Resolver name prefix for forms/classes - 'form.'
public const string FORM_PREFIX = "form."
Field Value
- string
Methods
BizFormFilesFolder()
Gets custom on-line form file folder path.
public static string BizFormFilesFolder()
Returns
- string
Value of custom on-line form file folder
ClearFormInfos(bool)
Clears cached FormInfo objects.
public static void ClearFormInfos(bool logTasks)
Parameters
logTasksboolIf true, web farm tasks are logged
EnsureDefaultValues(string, IDataContainer, FormResolveTypeEnum)
Ensures the default class values to the Data container for required fields (not allowing empty value) without a value.
[Obsolete("Method is deprecated and will be removed in the next version. Use LoadDefaultValues(string, IDataContainer, FormResolveTypeEnum) instead.")]
public static bool EnsureDefaultValues(string className, IDataContainer container, FormResolveTypeEnum resolveType = FormResolveTypeEnum.None)
Parameters
classNamestringClass name
containerIDataContainerData container
resolveTypeFormResolveTypeEnumType of macro resolving
Returns
- bool
Returns TRUE if at least one default value was ensured.
GetBasicFormDefinition(string)
Returns basic form definition of the table with primary key only.
public static FormInfo GetBasicFormDefinition(string primaryKey)
Parameters
primaryKeystringPrimary key name.
Returns
GetBizFormFilesFolderPath(string)
Returns BizForm files folder physical path according to 'CMSBizFormFilesFolder' settings key.
public static string GetBizFormFilesFolderPath(string webFullPath = null)
Parameters
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject). If it is not specified the web application physical path is used.
Returns
- string
GetBizFormTempFilesFolderPath(string)
Gets BizForm temporary files folder physical path based on GetTempFilesRootFolderPath(string).
public static string GetBizFormTempFilesFolderPath(string webFullPath = null)
Parameters
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject). If it is not specified the web application physical path is used.
Returns
- string
Returns folder path for form's temporary files.
GetDateTimeValueInSystemCulture(string, CultureInfo)
Gets date-time value in system (en) culture format.
public static string GetDateTimeValueInSystemCulture(string value, CultureInfo culture)
Parameters
valuestringValue to be converted
cultureCultureInfoCulture used for
valuestring formating.
Returns
- string
GetDateValueInSystemCulture(string, CultureInfo)
Gets date value in system (en) culture format.
public static string GetDateValueInSystemCulture(string value, CultureInfo culture)
Parameters
valuestringValue to be converted
cultureCultureInfoCulture used for
valuestring formating.
Returns
- string
GetDecimalValueInSystemCulture(string, CultureInfo)
Gets decimal value in system (en) culture format.
public static string GetDecimalValueInSystemCulture(string value, CultureInfo culture)
Parameters
valuestringValue to be converted
cultureCultureInfoCulture used for
valuestring formating.
Returns
- string
GetDoubleValueInSystemCulture(string, CultureInfo)
Gets double value in system (en) culture format.
public static string GetDoubleValueInSystemCulture(string value, CultureInfo culture)
Parameters
valuestringValue to be converted
cultureCultureInfoCulture used for
valuestring formating.
Returns
- string
GetFilePhysicalPath(string, string)
Gets path to the file in file system.
public static string GetFilePhysicalPath(string fileName, string webFullPath = null)
Parameters
fileNamestringFile name
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
Physical path
GetFormDefinitionDifference(string, string, bool)
Returns XML differences between original and alternative form definitions (i.e. returns only fields that differs from each other)
public static string GetFormDefinitionDifference(string original, string alternative, bool includeAllAltFields = false)
Parameters
originalstringDefault/original form definition
alternativestringAlternative form definition
includeAllAltFieldsboolIf true, result will contain even those fields which are not in the original definition
Returns
- string
GetFormInfo(string, bool, bool, bool)
Returns FormInfo object for specified class name or alternative name. Method loops through supplied class list and returns first object existing. If alternative name is specified then it is merged with default class and then returned If coupled class exists for given alternative form then it is merged as well. If alternative form info not found then its default class is returned. You can also merge two forms in the result by using the + operator between names, such as "customtable.sampletable.filter+customtable.sampletable.extra"
public static FormInfo GetFormInfo(string classes, bool clone, bool fallbackToDefault = true, bool onlyVisible = false)
Parameters
classesstringClass names or alternative names separated by semicolon
cloneboolWhen returned FormInfo is used only for reading then cloning can be set to FALSE
fallbackToDefaultboolIf true and alternative form is not found, the process attempts to fall back to the class default form
onlyVisibleboolIf true, only visible fields are provided in the result. This also removes any empty categories in the form (considering them invisible).
Returns
- FormInfo
Null if no FormInfo found for any of the specified classes. Otherwise returns first FormInfo which was found.
GetGuidFileName(string)
Returns file name in format [guid].[extension].
[Obsolete("Method is deprecated and will be removed in the next version.")]
public static string GetGuidFileName(string fileNamesString)
Parameters
fileNamesStringstringFile names from database in format "[guid].[extension]/[originalfilename].[extension]"
Returns
- string
GetOriginalFileName(string)
Returns file name in format [OriginalFileName].[extension].
[Obsolete("Method is deprecated and will be removed in the next version.")]
public static string GetOriginalFileName(string fileNamesString)
Parameters
fileNamesStringstringFile names from database in format "[guid].[extension]/[originalfilename].[extension]"
Returns
- string
GetPropertyMacroTransformation(IDictionary)
Returns a transformation action. If given macro table contains key passed to the action (second action parameter), it replaces current value (third action parameter) in the element passed to the action (first action parameter) and adds "ismacro" attribute to the element.
public static Action<XmlElement, string, object> GetPropertyMacroTransformation(IDictionary macroTable)
Parameters
macroTableIDictionaryMacro table for the properties.
Returns
- Action<XmlElement, string, object>
LoadDefaultValues(string, IDataContainer, FormResolveTypeEnum)
Loads the default class values to the Data container.
public static void LoadDefaultValues(string className, IDataContainer container, FormResolveTypeEnum resolveType = FormResolveTypeEnum.None)
Parameters
classNamestringClass name
containerIDataContainerData container
resolveTypeFormResolveTypeEnumType of macro resolving
MergeFormDefinitions(string, string, bool)
Merges original and alternative form definitions and returns the result.
public static string MergeFormDefinitions(string original, string alternative, bool includeAllAltFields = true)
Parameters
originalstringDefault/original form definition
alternativestringAlternative form definition (just differences from original)
includeAllAltFieldsboolIf true, result will contain even those fields which are not in the original definition (optional, default value is true)
Returns
- string
RemoveFieldFromAlternativeDefinition(string, string, int)
Removes field from alternative definition and keeps order of other items.
public static string RemoveFieldFromAlternativeDefinition(string formDefinition, string fieldName, int order)
Parameters
formDefinitionstringForm definition from which the item will be removed
fieldNamestringName of field which will be removed
orderintItem order in original form
Returns
- string
RemoveFieldFromAlternativeForms(DataClassInfo, string, int)
Removes field from alternative forms belonging to given class.
public static void RemoveFieldFromAlternativeForms(DataClassInfo formClassInfo, string fieldName, int order)
Parameters
formClassInfoDataClassInfoClass with alternative forms
fieldNamestringName of the deleted field
orderintOrder of deleted field in class