When EntityForm is submitted, there's this chain of methods:
- submitForm()
- buildEntity()
- copyFormValuesToEntity()
submitForm() calls cleanValues() on the form state, which removes values such as the form token and the form id from the form state values.
However, copyFormValuesToEntity() can't rely on this, because buildEntity() is also called from afterBuild(). That doesn't clean the form values, and indeed can't, as it's called when the form is built in the submit procedure.
The consequences of this are:
- Attempting to iterate over form values in copyFormValuesToEntity() in a subclass of EntityForm means internal values are found.
- Attempting to call cleanValues() in copyFormValuesToEntity() in a subclass of EntityForm causes the form to report an error, due to the form token being cleaned too early on
Comments