EntityForm::afterBuild() rebuilds the entity from submitted values even when the form is not being submitted, but fetched from cache.

So on an Ajax submit form that's two buildEntity() calls, one when the form is fetched from cache and processed (processingInput() is TRUE, submitted() is FALSE), and one when the actual form submit values are processed (processingInput() and submitted() are TRUE).

Wouldn't it be enough to updated the entity before processing submitted values ?

Comments

yched’s picture

Status: Active » Needs review
StatusFileSize
new2.02 KB

Patch, let's see what breaks ?

Status: Needs review » Needs work

The last submitted patch, 1: 2497981_EntityForm_buildEntity-1.patch, failed testing.

yched’s picture

Title: EntityForms call buildEntity() a lot on AJA » EntityForms call buildEntity() a lot on AJAX calls
Status: Needs work » Needs review
StatusFileSize
new730 bytes

wrong patch, and unfinished issue title - yched's attention span: 0

Status: Needs review » Needs work

The last submitted patch, 3: 2497981_EntityForm_buildEntity-3.patch, failed testing.

yched’s picture

Status: Needs work » Closed (won't fix)

So, looks like it's definitively needed - I still need to figure out the exact flow of FormObject::$entity regarding ajax submits, but for now, closing this.

amateescu’s picture

I also tried this in one of the iterations from #2448357: Config entity forms need to have access to an updated entity object at all times but I ended up at the same conclusion, both "builds" are needed :/