Answering my own question here in case in case it’s useful for anyone else in the future:
I followed the instructions here to register a custom form type FileFormFieldType.
And then my implementation of the class FileFormFieldType looks something like this:
public class FileFormFieldType extends SimpleFormFieldType {
public final static String FORM_TYPE = "file";
@Override
public String getName() {
return FORM_TYPE;
}
public TypedValue convertValue(TypedValue propertyValue) {
if(propertyValue instanceof FileValue) {
return propertyValue;
} else {
Object value = propertyValue.getValue();
if(value == null) {
return Variables.fileValue("null").create();
} else {
return Variables.fileValue((File) value);
}
}
}
@Override
public Object convertFormValueToModelValue(Object propertyValue) {
return null;
}
@Override
public String convertModelValueToFormValue(Object modelValue) {
return null;
}
}