You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to save an address through a custom module and set the scenario to Live, the validation returns errors that the fullName, organization, organizationTaxId en administrativeArea cannot be blank while they are filled in and the selected country doesn't have an administrativeArea.
Thanks for reporting that! This was happening because the validation rules were getting defined when you first called safeAttributes(), based on the default countryCode (us), and there’s no way to tell the model to refresh its validation rules once they’ve been defined.
Fixed for the next release by moving the county code (and field layout)-based required validation over to afterValidate().
What happened?
Description
When trying to save an address through a custom module and set the scenario to Live, the validation returns errors that the fullName, organization, organizationTaxId en administrativeArea cannot be blank while they are filled in and the selected country doesn't have an administrativeArea.
Custom code:
Data of address element before calling validate()
Expected behavior
Validate method returns true if the fields are filled in or not necessary
Actual behavior
Validate method returns errors on fields that are filled in
Craft CMS version
4.0.1
PHP version
8.0.8
Operating system and version
Linux 5.13.0-40-generic
Database type and version
MySQL 8.0.26
Image driver and version
Imagick 3.5.1 (ImageMagick 6.9.10-23)
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: