Q:

Selection field type elements cannot be shown. How to properly add a custom entity representation to Sulu form?

Following by Sulu documentation, I try to add selection field type to display collection type resource (Room object) in admin form. Currently, I can select these elements from list,
select element
selected element
but after form submit and reload any record cannot be shown, despite that the Room object exist in Event entity:
empty list
What I do wrong?
Code:
sulu_admin.yaml
sulu_admin:
...

# Registering Selection Field Types in this section
field_type_options:
    selection:
        room_selection:
            default_type: list_overlay
            resource_key: rooms
            types:
                list_overlay:
                    adapter: table
                    list_key: rooms
                    display_properties:
                        - name
                    icon: su-clock
                    label: 'app.rooms'
                    overlay_title: 'app.rooms'

event_details.xml
        <property name="rooms" type="room_selection">
             <meta>
                 <title>app.rooms</title>
             </meta>
        </property>

A:

Your api response should just contain a flat list of room ids for rooms. Assuming you have an Event entity with a $rooms property, add a public function getRoomIds() {} to your Event entity and add the @VirtualProperty("rooms") annotation to that method. Probably you have to add the @Exclude annotation to public function getRooms() {}
EDIT:
I just tried it, if you have an entity like the following, it works as expected. If it's still not working, maybe you have a problem with your jms serializer config.
/**
 * @Serializer\ExclusionPolicy("all")
 */
class Event
{
    /**
     * @Serializer\Expose()
     */
    private $otherProperty;

    /**
     * @var Collection<int, Room>
     */
    private $rooms;

    public function getRooms(): Collection
    {
        return $this->rooms;
    }

    /**
     * @Serializer\VirtualProperty()
     * @Serializer\SerializedName("rooms")
     */
    public function getRoomIds(): array
    {
        return $this->rooms->map(function (Room $room) {
            return $room->getId();
        });
    }
}

