I would like webform to also clear values when #states_clear = TRUE for disabled #states; while inputs that are disabled are still visible client-side, their values won't be submitted, so server-side they should be considered invisible.

CommentFileSizeAuthor
#2 3043475-2.patch570 bytescasey

Comments

casey created an issue. See original summary.

casey’s picture

Status: Active » Needs review
StatusFileSize
new570 bytes
jrockowitz’s picture

The attached webform replicates the issue and the issue is fixed using your patch.

I agree the disabled element values should be cleared because they are not submitted to the server. The problem is that I am sure some people are currently relying on the conditionally disabled element value to still be preserved.

A few options.

  • Display a warning on sites who are using conditionally disabled elements.
  • Convert conditionally disabled elements to readonly to preserve the data.
  • Wait until Webform 9.x-6.x to commit this change
jrockowitz’s picture

Priority: Normal » Major

Here is a link discussing and documenting that disabled element values are not sent to the server.

I am marking this a major because Webforms with disabled elements are not working as expected.

jrockowitz’s picture

Title: Also clear values when #states_clear = TRUE for disabled #states » [Webform 8.x-6.x] Also clear values when #states_clear = TRUE for disabled #states
Status: Needs review » Postponed

Postponing this change to Webform 8.x-6.x.

jrockowitz’s picture

Here is a really tricky related issue. Disabled managed file values are being lost when the managed file is disabled via JavaScript.

@see #3107168: Behaviour of file element if disabled

jrockowitz’s picture

Status: Postponed » Closed (won't fix)

I think this change is going to be to disruptive and potentially cause unexpected data loss.