EntityForm::buildEntity() and copyFormValuesToEntity() can't rely on having clean form values

Created on 9 February 2016, about 9 years ago
Updated 8 April 2025, 9 days ago

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

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

entity system

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    It has been over 9 years since there was work here. So, checking in here to find out if this is still relevant. Is it?

    I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks

  • 🇬🇧United Kingdom joachim

    EntityForm::buildEntity() is still called from afterBuild()

Production build 0.71.5 2024