if (FormElement.getFormElementTypes().contains(type)) {
result = new FormElement(type, properties);
} else if (type == ElementType.GADGET) {
result = new Gadget(properties);
} else if (type == ElementType.IMAGE) {
result = new Image(properties);
} else if (type == ElementType.ATTACHMENT) {
byte[] data = null;
String encodedData = properties.get(Attachment.DATA);
if (encodedData != null) {
try {