SimpleFormIterator issue when editing resources
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu với repository tái hiện được liên kết và tệp pwa/components/Admin.tsx của nó, đặc biệt là phép biến đổi dirtyFix trên phần tử Edit. Tái hiện luồng chỉnh sửa Author bằng cách thêm một Book thông qua SimpleFormIterator và kiểm tra array đã lưu để tìm các giá trị @id và @type rỗng. Hoàn thành khi Book lồng nhau mới có thể được lưu mà không gặp lỗi “No resource associated to ""”.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 !
- Ngôn ngữ chính
- TypeScript
- Star
- 516
- Fork
- 134
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của api-platform/admin
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
api-platform/admin#616 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 64/100
api-platform/admin#660 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
api-platform/admin#659 · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
api-platform/admin#631 · 6 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
api-platform/admin#626 · 1 bình luận · 1 reaction ·
Tất cả issue của api-platform/admin
Issue tương tự
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100