An editor is the user interface used to edit an entity and is made up of tabs and property editors.
The editor configuration is a sub configuration of a FluidityCollectionConfig
instance and is accessing via it’s Editor
method.
Accesses the editor config of the given collection.
// Example
collectionConfig.Editor(editorConfig => {
...
});
Adds a tab to the editor.
// Example
editorConfig.AddTab("General", tabConfig => {
...
});
Adds the given property to the editor.
// Example
editorConfig.AddField(p => p.FirstName, fieldConfig => {
...
});
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.
Sets the label for the editor field.
// Example
fieldConfig.SetLabel("First Name");
Sets the description for the editor field.
// Example
fieldConfig.SetDescription("Enter your age in years");
Sets the default value to a known constant.
// Example
fieldConfig.SetDefaultValue(10);
Sets the default value via a function that gets evaluated at time of entity creation.
// Example
fieldConfig.SetDefaultValue(() => DateTime.Now);
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();
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'}");
Makes the given field mandatory.
// Example
fieldConfig.MakeRequired();
Defines the regular expression to use when validating the field.
// Example
fieldConfig.SetValidationRegex("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");
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.
Set the data type of the current field to the Umbraco data type with the given name.
// Example
fieldConfig.SetDataType("Richtext Editor");
Set the data type of the current field to the Umbraco data type with the given id.
// Example
fieldConfig.SetDataType(-88);
Set the value mapper for the current field. See Value Mapper API documentation for more info.
// Example
fieldConfig.SetValueMapper<MyValueMapper>();
Set the value mapper for the current field. See Value Mapper API documentation for more info.
// Example
fieldConfig.SetValueMapper(new MyValueMapper());