Problem/Motivation
An entity reference field with the Complex widget is returning a vague error ("This value should not be null.") without indicating what field or value is incorrect. Sometimes nothing is incorrect, and it's the fact that inline_entity_form isn't adding values to the main entity before it's validated.
In some cases this is happening when all the fields are filled in, such as on clicking the "preview" button when adding a new node.
Steps to reproduce:
1) go to https://simplytest.me/ and select "Inline Entity Form" as the project
2) Once site launches, add an entity reference field on the article content type to reference the page content type
3) Edit the form display to use the Complex Widget widget.
4) Create a test page node (/node/add/page)
5) Go to create an article node (/node/add/article), fill in all the fields (including the reference to the page node you created
6) Click Preview
7) Observe error.
Expected: You should see a preview of your node with the image displaying
Actual: An error message "This value should not be null." and the form reloads. I traced it back to validation on the image field (see stack trace below).
Proposed resolution
I'm not sure of the best approach yet. I have a patch, but it needs review.
Next Steps
- test coverage to demonstrate the error
- needs review
- needs test coverage for the fix