Problem/Motivation
This issues described two (related) issues:
- Filling out a form with input fields for country, state/province and district/country throws an error if only country and state/province are filled out.
- Filling out a form with input fields for country, state/province and email throws an error.
Detailed steps to reproduce (issue 1)
Configure form
- CiviCRM → Check Enable CiviCRM Processing
- Number of Contacts:
1 - 1. Contact 1? → Number of Address Fields:
1 - Address 1 (Primary) → Choose Country, State/Province and District/County
Fill form
- Country: Malaysia
- State/Province: Selangor
- District/County: - First Choose a State -
- Submit
Receive error inside logs
- Location:
https://<domain>/webform-civicrm/js/county/10-1131 - Message:
CiviCRM_API3_Exception: Expected one StateProvince but found 0 in civicrm_api3() (line 134 of /var/www/<domain>/vendor/civicrm/civicrm-core/api/api.php). - Severity: Error
Detailed steps to reproduce (issue 2)
Configure form
- CiviCRM → Check Enable CiviCRM Processing
- Number of Contacts:
1 - 1. Contact 1? → Number of Address Fields:
1 - Address 1 (Primary) → Choose Country and State/Province
- 1. Contact 1? → Number of Email Fields:
1
Fill form
- Country: Malaysia
- State/Province: Selangor
- Email: anything, e.g. test@invalid
- Submit
Receive errors
Forms dooes not show a submission message, but only says "The website encountered an unexpected error. Please try again later.".
The following errors appear in the log:
Error 1
- Type: webform_submission
- Message:
CiviCRM_API3_Exception: Expected one StateProvince but found 0 in civicrm_api3() (line 134 of /var/www/<domain>/vendor/civicrm/civicrm-core/api/api.php). - Severity: Error
Error 2
- Type: php
- Message:
Drupal\Core\Entity\EntityStorageException: Expected one StateProvince but found 0 in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of /var/www/<domain>/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). - Severity: Error
Proposed resolution
Do not throw an error.
Comments
Comment #2
fkohrt commentedComment #3
fkohrt commentedComment #4
fkohrt commentedComment #5
fkohrt commentedComment #6
fkohrt commentedComment #7
karingComment #8
jitendrapurohit commented@fkohrt I've submitted a patch at https://github.com/colemanw/webform_civicrm/pull/612. Can you pls confirm if it fixes the above problem?
Thanks.
Comment #9
karingHi Florian - can you please test/confirm ->we believe this fixes the issue.
https://github.com/colemanw/webform_civicrm/pull/612
Thank you 👏 for being a sponsor of the module!
Comment #10
fkohrt commentedHi Karin and @jitendrapurohit, thanks a lot for tackling this! I can confirm the patch fixes the issue :)
Comment #11
karingExcellent 🎉 merging and marking as fixed.