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

allow non boolean simple conditionals #454

Merged
merged 6 commits into from
May 15, 2024
Merged

Conversation

mc0918
Copy link
Contributor

@mc0918 mc0918 commented May 8, 2024

Overview

Previously, the SimpleConditional logic only checked for an array key and its value, i.e.

[
  'when' => 'key',
  'equalTo' => 'value',
  'show' => true
]

for formio data like:

[
  'submissionValues' => [
    'key' => 'value'
  ]
]

However, SelectBoxes and Select with the multivalue option enabled format their values differently, leading to SimpleConditional::invoke() always returning false and the components' values being ignored during validations. An example in SOAP is, because the values of these ignored components are not persisted, missing PDF uploads:
Screenshot (221)

This PR expands the SimpleConditional logic to cover these cases, handling the following:

// SelectBoxes tracks each selected option by setting the corresponding key to true
'submissionValues' => [
    'key' => [
        'option1' => true,
        'option2' => false,
    ],
],

and

// multivalue Select components track each selected option via an array of selected option keys
'submissionValues' => [
    'key' => [
        'option1', 'option2'
    ],
],

So now all the conditionals shown below just work(tm), and values will be persisted.
aaaaaaa

Checklist

  • tests/ added or updated
  • CHANGELOG.md's Unreleased section is updated
  • Documentation is updated

Copy link

github-actions bot commented May 8, 2024

Test Results

841 tests  +2   841 ✅ +2   34s ⏱️ -2s
124 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit c7577a4. ± Comparison against base commit 8bc15d8.

♻️ This comment has been updated with latest results.

@coveralls
Copy link

Coverage Status

coverage: 95.532% (+0.02%) from 95.514%
when pulling c7577a4 on allow-select-box-conditionals
into 8bc15d8 on develop.

@mc0918 mc0918 marked this pull request as ready for review May 9, 2024 14:44
@mc0918 mc0918 requested a review from a team as a code owner May 9, 2024 14:44
@nie7321 nie7321 merged commit 2b1a9ea into develop May 15, 2024
5 checks passed
@nie7321 nie7321 deleted the allow-select-box-conditionals branch May 15, 2024 13:35
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

Successfully merging this pull request may close these issues.

3 participants