API

Editor

An editor is the user interface used to edit an entity and is made up of tabs and property editors.

Configuring an editor

The editor configuration is a sub configuration of a FluidityCollectionConfig instance and is accessing via it’s Editor method.

Editor(Lambda editorConfig = null) : FluidityEditorConfig<TEntityType>

Accesses the editor config of the given collection.

// Example
collectionConfig.Editor(editorConfig => {
    ...
});

Adding a tab to an editor

AddTab(string name, Lambda tabConfig = null) : FluidityTabConfig<TEntityType>

Adds a tab to the editor.

// Example
editorConfig.AddTab("General", tabConfig => {
    ...
});

Adding a field to a tab

AddField(Lambda propertyExpression, Lambda propertyConfig = null) : FluidityEditorFieldConfig<TEntityType, TValueType>

Adds the given property to the editor.

// Example
editorConfig.AddField(p => p.FirstName, fieldConfig => {
    ...
});

Changing the label of a field

By default Fluidity will build the label from the property name, including splitting camel case names into sentence case, however you can set an explicit label if you’d prefer.

SetLabel(string label) : FluidityEditorFieldConfig<TEntityType, TValueType>

Sets the label for the editor field.

// Example
fieldConfig.SetLabel("First Name");

Adding a description to a field

SetDescription(string description) : FluidityEditorFieldConfig<TEntityType, TValueType>

Sets the description for the editor field.

// Example
fieldConfig.SetDescription("Enter your age in years");

Setting the default value of a field

SetDefaultValue(TValueType defaultValue) : FluidityEditorFieldConfig<TEntityType, TValueType>

Sets the default value to a known constant.

// Example
fieldConfig.SetDefaultValue(10);

SetDefaultValue(Func defaultValueFunc) *: FluidityEditorFieldConfig<TEntityType, TValueType>*

Sets the default value via a function that gets evaluated at time of entity creation.

// Example
fieldConfig.SetDefaultValue(() => DateTime.Now);

Making a field read only

MakeReadOnly() : FluidityEditorFieldConfig<TEntityType, TValueType>

Makes the current field read only disabling editing in the UI. A ReadOnly property cannot have a custom DataType, ValueMapper or ValidationRegExp.

// Example
fieldConfig.MakeReadOnly();

MakeReadOnly(Func<TValueType, string> format) : FluidityEditorFieldConfig<TEntityType, TValueType>

Makes the current field read only disabling editing in the UI. A ReadOnly property cannot have a custom DataType, ValueMapper or ValidationRegExp. Provides a custom formatting expression to use when rendering the value as a string.

// Example
fieldConfig.MakeReadOnly(distanceProp => $"{distanceProp:## 'km'}");

Making a field mandatory

MakeRequired() : FluidityEditorFieldConfig<TEntityType, TValueType>

Makes the given field mandatory.

// Example
fieldConfig.MakeRequired();

Validating a field

SetValidationRegex(string regex) : FluidityEditorFieldConfig<TEntityType, TValueType>

Defines the regular expression to use when validating the field.

// Example
fieldConfig.SetValidationRegex("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");

Changing the data type of a field

By default Fluidity will automatically choose a relevant data type for simple field types, however you can override this should you wish to use an alternative data type.

SetDataType(string dataTypeName) : FluidityEditorFieldConfig<TEntityType, TValueType>

Set the data type of the current field to the Umbraco data type with the given name.

// Example
fieldConfig.SetDataType("Richtext Editor");

SetDataType(int dataTypeId) : FluidityEditorFieldConfig<TEntityType, TValueType>

Set the data type of the current field to the Umbraco data type with the given id.

// Example
fieldConfig.SetDataType(-88);

Setting a field value mapper

SetValueMapper<TMapperType>() : FluidityEditorFieldConfig<TEntityType, TValueType>

Set the value mapper for the current field. See Value Mapper API documentation for more info.

// Example
fieldConfig.SetValueMapper<MyValueMapper>();

SetValueMapper(FluidityMapper mapper) : FluidityEditorFieldConfig<TEntityType, TValueType>

Set the value mapper for the current field. See Value Mapper API documentation for more info.

// Example
fieldConfig.SetValueMapper(new MyValueMapper());