Closed (won't fix)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Feb 2018 at 11:16 UTC
Updated:
1 Nov 2018 at 00:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
spadxiii commentedComment #3
spadxiii commentedForgot to make the field title translatable... so new patch!
Comment #4
jrockowitz commentedWe already have an 'Exclude empty elements' setting for
the Preview page (/admin/structure/webform/manage/contact/settins/form) and Email handlers (/admin/structure/webform/manage/contact/handlers)
The exclude empty behavior only excludes empty strings and does not exclude a checkbox set to FALSE or number input set to '0'.
@see \Drupal\webform\Plugin\WebformElementBase::build
I think we could enhance/piggy-back on this existing feature. Maybe we should added an '#exclude_empty' property to all elements that is stricter and specific to the element's data type. For example, a checkbox set to FALSE would be considered empty, and a number input set to '0' would be considered empty.
Some notes/thoughts...
Comment #5
spadxiii commentedThe 'Exclude empty elements' was not sufficient for unchecked checkboxes, because they have 2 values: 1 and 0 (or Yes and No) from the boolean element. It's not possible for the current checkbox to get the value of an empty string.
I think it's a good idea to have some configuration option per element to control what is empty.
About your last note/thought: I'm sure there are use-cases to be found where you would exclude an unchecked checkbox in one email, but not another. If you move the exclude-setting to the element, it would be excluded in all handlers. The way it currently works is fine, except that some elements need more control over what is considered "empty".
Comment #6
jrockowitz commentedThe most immediate work-around is to use 'Checkboxes' with only a single option.
Comment #7
jrockowitz commentedThe workaround in #6 is a good immediate solution otherwise I think this feature should be handled via custom code.
Comment #8
jrockowitz commented@SpadXIII I did wind up implementing this feature and using your patch as the starting point.
@see #2977378: Add 'exclude unselected checkboxes' from email notification and preview.
Comment #9
electrokate commented@jrockowitz, for the life of me I cannot find where to edit this setting. I see that you added the patch in #3, can you tell me how to exclude empty checkboxes? I have looked everywhere and it is not visible to me.
Comment #10
jrockowitz commented