Provinces with a Civi id > 9999 crash a form on submission

Created on 9 February 2023, over 1 year ago
Updated 27 February 2023, over 1 year ago

1.0 Problem/Motivation

When you submit an address, and the CiviCRM id of the state/province is > 9999, you get two errors:

CRM_Core_Exception: Value for abbreviation is 5 characters - This field has a maxlength of 4 characters. in civicrm_api3() (line 135 of /code/vendor/civicrm/civicrm-core/api/api.php).

Drupal\Core\Entity\EntityStorageException: Value for abbreviation is 5 characters - This field has a maxlength of 4 characters. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of /code/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This happens because of PR #813, "Replace state abbreviation with id on normal address state field". We still try to convert the abbreviation to an ID. Which is fine if it's already an ID - unless the API call fails. Which it does because "abbreviation" has a maxlength of 4.

2.0 Detailed steps to reproduce (embed screenshots)

Create a form with a contact and address. Enable country and state/province.

Select a country of "United Kingdom" and state/province of "Derry City and Strabane". Note that the province list isn't alphabetical anymore, but that's out of scope here.

Submit.

3.0 Proposed resolution

I have a patch incoming.

πŸ› Bug report
Status

Fixed

Version

6.0

Component

Webform/Drupal

Created by

πŸ‡ΊπŸ‡ΈUnited States MegaphoneJon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024