Unable to use SourceCodeEditor in FieldGroup

Hi, My entity has an attribute “content” which is actuall HTML so I would like to use the SourceCodeEditor component in the FieldGroup instead of the TextField. I tried the following code in the init method:

SourceCodeEditor sourceCodeEditor = componentsFactory.createComponent(SourceCodeEditor.class)
fieldGroup.getFieldNN("content").setComponent(sourceCodeEditor)

But I get
IllegalStateException: Unable to change component for bound FieldConfig

I set the field custom property to true:

<field property="content" custom="true">

The editor then comes up with the SourceCodeEditor component but it does not show the content value. I guess this should be expected since the documentation says the custom true attribute means the field identifier does not refer to an entity attribute.

Is this expected behavior? If so, then how do I accomplish this? Is it something like overriding the postInit and getItem methods in the AbstractEditor? Thanks.

Hello,
In the first case, everything is OK - you cannot reassign a component for a field that has already created.
In the second case, the problem is that documentation doesn’t have an important information - you should manually set data source and property to a component that you use with a field.
An issue was created and you can find it here.
Best regards,
Daniil.

Thanks for the issue and guidance. Manually setting the datasource and property was an easy solution. Thanks.