The reason for this is not trivial, and it's somewhat related to #1065458: Required fields in step >1 break multistep.

The basic problem is that the #access is only applied on rendering and the form API doesn't know about it. Which means that when the form is submitted and validated, the cached form data does not have #access set. So it attempts to read the input.

This works for most form fields like simple text fields, but fails on file_managed fields because they end up with weird defaults instead of the existing values.

I am currently not sure how to fix this correctly, multistep probably needs to set #access = FALSE on all multistep groups which are not the current step. That's why the function from there could help here.

I am not sure if it is possible to fix the inconsistency (not sure if it is actually a bug) in core. I have been able to hack around it, but the hack is wrong by definition.

Comments

berdir’s picture

Status: Active » Closed (duplicate)

Looks like my patch at #1470482: Image/File fields lose their values when submitting another step is in fact already enough to prevent this.