Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agree field doesn't return checked / unchecked values via submission getFieldValues function. #2288

Open
DanielDarrenJones opened this issue Feb 12, 2025 · 3 comments

Comments

@DanielDarrenJones
Copy link

Describe the bug

When getting field values from a submission using the getFieldValues() function the agree field returns true or false rather than the values assigned in the checked / unchecked options.

Here is the field config:
Image

And the data returned from the function call:

array:11 [▼
  "firstName" => "Daniel"
  "lastName" => "Jones"
  "emailAddress" => "dan@****.com"
  "telephone" => verbb\formie\models\Phone {#692 ▶}
  "destination" => verbb\formie\fields\data\MultiOptionsFieldData {#719 ▶}
  "whereWouldYouLikeToTravel" => verbb\formie\fields\data\MultiOptionsFieldData {#739 ▶}
  "budget" => verbb\formie\fields\data\SingleOptionFieldData {#744 ▶}
  "Comments" => "Test"
  "newsletter" => true
  "page" => "http://****.test/contact_us"
  "referer" => "http://****.test/"
]

Steps to reproduce

  1. Create agree field with an checked values of yes and unchecked of no
  2. retrieve the submission via code, and call the getFieldValues() function on it

Form settings

  • Multi-page form: No
  • Submission Method: Page Reload
  • Client-side Validation: No
  • Custom Form Templates: No

Craft CMS version

5.5.9

Plugin version

3.0.16

Multi-site?

No

Additional context

No response

@engram-design
Copy link
Member

Yeah, the Agree field is a tricky one in this situation. For integrations, it's almost always the case that it needs to be a boolean value. Both for the opt-in fields that are typically mapped to it, and to be compatible with provider fields like checkboxes.

We'll need to look at refactoring this for a few different areas to ensure we don't introduce a breaking change.

@DanielDarrenJones
Copy link
Author

DanielDarrenJones commented Feb 12, 2025

Would it be possible to introduce a way of flagging that it should be called with checked unchecked values potentially, that way it's not breaking, maybe as a parameter or something?

Or even a separate function we can call?

@engram-design
Copy link
Member

For sure, just working through updating a few things. Just wanted to mention there's a few moving parts to factor in so bare with me on this one, as it might not be an immediate fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants