Skip to content

Conversation

@saifsultanc
Copy link
Contributor

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

…ount checkboxes that match the values given.
Copy link
Contributor

@spivurno spivurno left a 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.
@saifsultanc
Copy link
Contributor Author

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.

As mentioned, updated to 'Any' instead of 'All'. Thanks @spivurno !

@saifsultanc saifsultanc requested a review from spivurno December 2, 2022 18:43
Copy link
Contributor

@claygriffiths claygriffiths left a 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.
Copy link
Contributor

@spivurno spivurno left a 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.
@saifsultanc
Copy link
Contributor Author

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 ),
) );

Ohh Gosh! Thanks so much for pointing that out @spivurno. Have fixed it. Appreciate all the feedback 🙌.

@saifsultanc saifsultanc requested a review from spivurno December 6, 2022 11:06
Copy link
Contributor

@spivurno spivurno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well! ✅

@saifsultanc saifsultanc merged commit 52d9a48 into master Dec 6, 2022
@saifsultanc saifsultanc deleted the saif/update/41352-gw-choice-count-count-specific-values branch December 6, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants