EAV - create a new form attribute
How to implement creation of a new form attribute (EAV) of a specific type?
Code list type
Following snippet creates a new EAV with the code and name "mailType" in the main IdmIdentity form definition. The values of the EAV attribute will be taken from a code list with the code "possibleMailTypes".
IdmFormDefinitionDto mainDefinition = formService.getDefinition(IdmIdentity.class); IdmFormAttributeDto eavAttribute = new IdmFormAttributeDto(); eavAttribute.setCode("mailType"); eavAttribute.setFormDefinition(mainDefinition.getId()); eavAttribute.setName("mailType"); eavAttribute.setConfidential(false); eavAttribute.setRequired(false); eavAttribute.setReadonly(false); eavAttribute.setPersistentType(PersistentType.CODELIST); eavAttribute.setFaceType("possibleMailTypes"); formAttributeService.save(eavAttribute);