admin icon indicating copy to clipboard operation
admin copied to clipboard

Subobjects not shown or crash Admin

Open ili101 opened this issue 1 year ago • 0 comments

API Platform version(s) affected: 3.2.16

Description
With readableLink false Collection displayed as links, single is empty:

    #[Groups(groups: ['Main:write'])]
    #[ORM\OneToMany(mappedBy: 'main', targetEntity: Sub::class, orphanRemoval: true, cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    #[ApiProperty(readableLink: false, writableLink: false)]
    private Collection $subs;

    #[Groups(groups: ['Main:write'])]
    #[ApiProperty(readableLink: false, writableLink: false)]
    #[ORM\ManyToOne(inversedBy: 'mains', cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    private ?One $one = null;

image

With readableLink true Collection displayed as json:

    #[Groups(groups: ['Main:write'])]
    #[ORM\OneToMany(mappedBy: 'main', targetEntity: Sub::class, orphanRemoval: true, cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    #[ApiProperty(readableLink: true, writableLink: true)]
    private Collection $subs;

image

With readableLink true Object, Admin crashes:

    #[Groups(groups: ['Main:write'])]
    #[ApiProperty(readableLink: true, writableLink: true)]
    #[ORM\ManyToOne(inversedBy: 'mains', cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    private ?One $one = null;

image

Unhandled Runtime Error
TypeError: data.map is not a function

Unhandled Runtime Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `CustomError`.

How to reproduce Full example: https://github.com/ili101/api-platform/tree/adminTest

ili101 avatar Mar 17 '24 22:03 ili101