I maintain a contrib module that implements hook_webform_submission_presave. It does some complex stuff which boils down to taking the submitted values and storing them in another database.

Here's the problem: if the field was hidden we want to treat it differently. As of Webform 4, conditional fields are built-in to the core webform module. But looking at the submission object, I can't tell the difference between a field that is blank because it was intentionally left blank by the user vs a field that is blank because it was hidden by a conditional rule. In the latter case, we don't want to overwrite an existing value in the other database, because the user wasn't telling us "I want this field to be blank" they were in fact telling us nothing about the field because they didn't even see it.

For more information about the scenario see the original issue.


Assuming you know the numeric id of your field (for example let's say it is 5)

If $submission->data[5] is an array, then the field was submitted. The array may contain an empty string, which means the field was left blank.

If $submission->data[5] === NULL then the field was not submitted because it was hidden by a conditional rule, or was excluded from the form for another reason (e.g. the user did not have permission to see it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.