- π©πͺGermany Anybody Porta Westfalica
This would actually still be useful.
- Status changed to Needs work
almost 2 years ago 6:27pm 27 February 2023 - πΊπΈUnited States dww
Thanks for keeping this moving. However, back to needs work for the following:
- Still needs tests (per #8).
- Still needs an upgrade path (also per #8).
- A "disable X" checkbox is an anti-pattern for a UI. You should check a box when you want something to happen, not when you want it not to happen. The patch in #5 got this right: it was a setting called "Validate address format"m that defaulted to TRUE, that you had to uncheck if you wanted to disable validation. Patch #9 inverted it and the later patches continued the inversion. We need to re-invert this back to "Validate postal code" or something.
Thanks again!
-Derek - πΊπΈUnited States bogdog400
This would be useful to me too. I'm getting grief for some postal codes now. Specifically US codes with more than 5 digits.
- πΊπΈUnited States bogdog400
I had quite a bit of trouble with this validation because I was using the JSON API and that's a bit harder to debug. I'm including this note just in case it helps someone else.
This is logging code wouldn't work for me when I inserted it in core/modules/jsonapi/src/Exception/UnprocessableHttpEntityException.php
\Drupal::logger('myerror')->warning('This is my error:'. print_r($violations) );
But this did:
\Drupal::logger('myerrror')->warning('This is my error:'. $this->$violations->getFieldNames() );
It didn't generate the kind of log that I wanted, though. But the log message said that "getFieldNames" didn't exist and then it included a nice print out of the rest of the object.
I'm fully aware that i wasn't doing the right thing with the PHP, but it was rather maddening and I'm leaving this as a potential help for others who experience it.
- last update
over 1 year ago 25 pass, 2 fail - π§πͺBelgium RandalV
Ugh, seems like I forgot to add some use statements in the previous patch, apologies.
Attached should be the fully working patch. - last update
over 1 year ago 32 pass - Assigned to sickness29
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 10:53am 20 November 2023 - last update
about 1 year ago 36 pass - πΊπ¦Ukraine sickness29
Hello there,
I took patch from #5 as base and added post_update hook for existing address fields and also added address validation test.
I have also added similar test here https://www.drupal.org/project/address/issues/2994943#comment-15323637 β¨ The address element should strip trailing whitespace from input Needs review , so would be good to combine those into one and move all data to single data provider. Let me know what you think - Status changed to Needs work
about 1 year ago 10:50am 3 December 2023 - π·πΈSerbia bojanz
As mentioned in #14, this setting should be "validate_postal_code", not "validate_address_format".
The user cares about not validating postal codes, they don't even know what an address format is.
We will also need to add a setting to the AddressFormatConstraintValidator in commerceguys/addressing that allows postal code validation to be turned off, then pass that setting along. We can't just turn off the entire validator because that would be a problem for REST users (which would lose required field validation, subdivision validation, etc).
Question: Do we actually need an update hook if we're setting the default value? Shouldn't Drupal be always adding the default value for us?
- π·πΈSerbia bojanz
Bumping to 2.0.x since this will require a library update.
- Status changed to Needs review
about 1 year ago 3:47pm 26 December 2023 - last update
about 1 year ago 38 pass - πΊπ¦Ukraine sickness29
Hi @bojanz
I have renamed the setting and applied code changes to 2.0.x.
Added new setting to constraint as well.
Tested with existing field and getSetting only looks for field config values, defaultFieldSettings is only used when new field is created, so I left post update function to update existing field config. - π·πΈSerbia bojanz
Patch looks good, now we need to implement the library side.
Leaving that on my plate for 2024.
- last update
about 1 year ago 47 pass - π·πΈSerbia bojanz
Updating version. We will commit this for Address 2.1.0.
I've done what I promised in #24, the library has been fixed, now it just needs a new release.
-
bojanz β
committed 1dc5ab26 on 2.x
Issue #3091072 by RandalV, andrewmacpherson, sickness29, jdleonard,...
-
bojanz β
committed 1dc5ab26 on 2.x
- Status changed to Fixed
12 months ago 2:24pm 25 February 2024 Automatically closed - issue fixed for 2 weeks with no activity.