Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

SimpleFormIterator issue when editing resources

Open
#485 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start with the linked reproduction repository and its pwa/components/Admin.tsx file, especially the dirtyFix transform on the Edit element. Reproduce the Author edit flow by adding a Book through SimpleFormIterator and inspect the saved array for empty @id and @type values. Done means the new nested Book can be saved without the “No resource associated to ""” error.

Written by the indexing model from the issue text.

Description

bug

API Platform version(s) affected: 3.0.2 (also 2.6.8 with last Admin version)

Description
Since react-admin 4.4+, I am not able to dynamically create sub-elements when editing a resource. Let's say I have Book and Author resources, you can create books from the Author edit page thanks to an ArrayInput and a SimpleFormIterator. When I tried to add Books to an Author with the Author edit page, the following error occurred : No resource associated to "".

How to reproduce
Here is an example repo to reproduce my issue : https://github.com/gaspardphilibert/issue-api-platform-admin-simpleformiterator. To experience the bug, you can create an Author with one Book, then edit the Author and try to add another Book. You shouldn't be able to add the second Book.

The reason
Version 4.4.0 of react-admin fixes an issue (https://github.com/marmelab/react-admin/pull/8204) linked to SimpleFormIterator default values when adding a record. It seems that it takes the first array value and reset its fields to make a default value for new elements. Obviously, during the process an empty @id field is also injected. So, when I add a new value in my SimpleFormIterator and save the entity, it sends the array with an item with an empty string @id. Like this for example :

{
    "@context": "/contexts/Author",
    "@id": "/authors/1",
    "@type": "Author",
    "name": "Shakespeare",
    "books": [
        {
            "@id": "/books/1",
            "@type": "Books",
            "name": "Roméo et Juliette"
        },
        {
            "@id": "",
            "@type": "",
            "name": "Macbeth"
        }
    ],
    "id": "/authors/1"
}

Hence the No resource associated to "". error.

Possible Solution
I used the transform property (dirtyFix function in my example repo) on the Edit element to remove the empty @id and it worked well but I am wondering if it's the best solution (I am quite new in the API Platform world, maybe it could be solved at a lower level).

Thanks for your help !

Dominant language
TypeScript
Stars
516
Forks
134
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from api-platform/admin

All issues in api-platform/admin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.