Problem/Motivation

After upgrading to the last version of Webform, checkbox values return a default value in the email confirmation/notification sent to the user, regardless if a custom value is set under: Build > Elements > Edit "My-Checkbox-Field" > "Advanced" > "Return/Default Value" field.
Before the upgrade it worked as expected.

To be more clear: I have a checkbox field not selected by default. If a user select the checkbox it should return in the e-mail the value I set in the custom field under "Advanced" field configuration, in my case "Voglio ricevere la demo", but when I fill in the form for a test, in the mail I receive the value "Yes" under the field label.

Additional Info: I'm using SMTP mail to send e-mail and MailSystem has module specific configuration for webform: Webform PHP mailer both in Format and in Sender.

All the project is updated to the last current version (drupal 8.9.13, Mail System 8.X.4.3, SMTP 8.x.1.0).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

tiikeri created an issue. See original summary.

marcusvsouza’s picture

Assigned: Unassigned » marcusvsouza

Working on it!

marcusvsouza’s picture

Status: Active » Needs review
StatusFileSize
new845 bytes

Here's a patch to solve this problem.

Status: Needs review » Needs work

The last submitted patch, 3: 3209476-Checkbox-doesnt-return-custom-value-in-the-email-notification-confirmation-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tiikeri’s picture

Dear Marcus, thanks a lot for taking care of this bug.
I tested the patch against the last version of Webform 6 and drupal core 8.9.14 and it seems to works well.
Still not tested against drupal 9 (where the automated test failed).
I will test it on tomorrow and get back with a feedback.

jrockowitz’s picture

Version: 6.0.2 » 8.x-5.x-dev
StatusFileSize
new3.12 KB

I am not able to find any regressions. The #return_value support was added via #3116535: Allow checkbox element's return (raw) value to be customized.

Still, I think making it possible to display the #return_value should be easier. The attached patch adds a 'Return value' form option to all boolean elements.

This issue should also be fixed via 8.x-5.x.

jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

The attached patch should work in 6.x and 8.x-5.x

Status: Needs review » Needs work

The last submitted patch, 6: 3209476-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

StatusFileSize
new548 bytes

I keep looking at the code, and the #return_value support never displayed the return value unless the checkbox's format was set to 'Raw value.'

I don't think we want to change this behavior. If you want to display the #return_value, you need to set the format to 'Raw value.'

The simplest solution to change 'Raw value' to 'Raw/return value' in the element edit form.

marcusvsouza’s picture

Status: Needs review » Reviewed & tested by the community

Tested, the patch applies properly and works as expected in comment #11

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz authored fb3dc4f on 8.x-5.x
    Issue #3209476 by jrockowitz, marcusvsouza: Checkbox doesn't return...

  • jrockowitz authored fb3dc4f on 6.x
    Issue #3209476 by jrockowitz, marcusvsouza: Checkbox doesn't return...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lindsay.wils’s picture

Sorry to reopen an old issue, but I am seeing some odd results here.

Setting my checkbox as explained with raw value, the results are showing always as 0, which seems to be due to line 42 on BooleanBase.php

return ($element['#return_value']) ? $value : 0;

changing to

return $element['#return_value'];

and then the custom return value shows correctly on the webform submission result page.

I am using a remote post to submit this data to an external system and believe this to be the reason Im not seeing the expected results.

Could I be onto something here?

Sorry, Im not up to speed on creating patches and tests...