- Strapi Version: 4.8.2
- Operating System: macOS 13.2.1
- Database: postgres:latest (15.2)
- Node Version: v16.17.0
- NPM Version: 8.15.0
- Yarn Version: 1.22.19
I have a Collection Type “Article” which has a field typed as a Component “Author”. This Author field is an optional field. However, the Component Author defines a required field “name”. Strapi by default adds an Author with empty values which will throw an error on Save:
While this behaviour partly makes sense (field “name” is required), it adding an undefined author impossible (while it should be possible since Author is an optional field). If I click the “Bin” icon, then click “Save” it will return to the default values of the Author which is the same as above just without the error message. Therefore, saving an “undefined Author” is not possible.
The expected behaviour would be the following: by default, do not add an empty Author, instead show the text “No entry yet. Click on the button below to add one.” to add an empty Author - This is the same screen as you would get when pressing the “Bin” icon. (Can’t add more images to the post, but here is what I mean: Screenshot of no entry)
Is there a workaround for this other than marking the name field of Author optional? Or is there something I missed in this process?
PS: a workaround could be to make Author a Collection type and make a one-to-many relation between Article and Author. However, this would not allow the user to add a new Author from the “new Article view”. Has anyone found a solution to add new entities from one side of the relation to the other? Example: user creates a new Article, searches for “John Doe” in the Author field. Since John Doe does not exist in the Authors, the interface suggest to “Add John Doe as an Author” instead of making the user manually navigate to the Author page and add it manually.