-
Notifications
You must be signed in to change notification settings - Fork 92
gw-choice-counter.php: Updated snippet with a values parameter to count checkboxes that match the values given.
#586
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
gw-choice-counter.php: Updated snippet with a values parameter to count checkboxes that match the values given.
#586
Conversation
…ount checkboxes that match the values given.
spivurno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
One functional change. Any matched value should count. So if you have checkboxes for:
- First Choice
- Second Choice
- Third Choice
- Fourth Choice
And the "values" parameter is set to array( 'First Choice', 'Second Choice' ), the count would be 1 because "First Choice" is checked.
- First Choice
- Second Choice
- Third Choice
- Fourth Choice
This configuration would give a count of 2 because "First Choice" and "Second Choice" are checked.
…ount checkboxes that match the values given.
As mentioned, updated to 'Any' instead of 'All'. Thanks @spivurno ! |
claygriffiths
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferring to @spivurno for final review on this one. Otherwise, LGTM on first glance!
…ount checkboxes that match the values given.
spivurno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to work if no "values" parameter is passed. I would expect all checkboxes to count in that case.
new GW_Choice_Count( array(
'form_id' => 595,
'count_field_id' => 4,
'choice_field_ids' => array( 1, 3 ),
) );
…ount checkboxes that match the values given.
Ohh Gosh! Thanks so much for pointing that out @spivurno. Have fixed it. Appreciate all the feedback 🙌. |
spivurno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working well! ✅
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2083255684/41352?folderId=3808239
Summary
The 'values' parameter added. This can be passed as an array of values, and the checkboxes will only be counted if values match that array.
Here is screencast: https://www.loom.com/share/7b8e9acd886247b8887ec56022ce363a