Is it possible to map Umbraco Forms data types into default Umbraco Data Types?
What I mean is something like this
foreach (var set in form.AllFieldSets)
{
var safeAlias = set.Caption.ToSafeAlias(shortStringHelper, true);
if (type.PropertyGroups.SingleOrDefault(x => x.Alias == safeAlias) is null)
type.AddPropertyGroup(safeAlias, set.Caption);
foreach (var field in set.AllFields)
{
var dataType = dataTypeService.GetDataType(field.SOMETHING); // get the equivalent data type
type.AddPropertyType(dataType);
}
}
In other words,
Get the equivalent Umbraco Datatype from a Form Field (data type) in order to add to a document type or member type.
Any suggestions or help will be much appreciated!
EDIT
I got as far as getting the details for the field using code from Umbraco Forms
public static class FieldTypeExtensions
{
public static bool TryGetFieldTypeForFieldId(Form form, Guid fieldId, IFieldTypeStorage fieldTypeStorage, out FieldType? fieldType)
{
Field field = form.AllFields.SingleOrDefault((Field x) => x.Id == fieldId);
if (field is null)
{
fieldType = null;
return false;
}
fieldType = fieldTypeStorage.GetFieldTypeByField(field);
return fieldType is not null;
}
}
But I still haven’t figured out how to map that field into a data type.
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/111352-mapping-umbraco-form-data-types-to-default-umbraco-data-types