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

Admin address fixes and extra address validation #2371

Merged
merged 3 commits into from
Nov 15, 2017

Conversation

jordan-brough
Copy link
Contributor

Please see individual commits.

Admin: state_id wasn't being cleared in some cases when changed via the admin.
Core: Add an address validation to ensure that a state always matches the country if presence.

… states

If you had a country without states + a manually typed-in `state_name` and then
switched to a country with states, the form would still submit the old
state_name alongside the new state_id.

This updates the js code to disable both state inputs (`state_name` and
`state_id`) by default and then re-enable whichever one ended up being used.
This is the same thing we were already doing for hiding & showing the inputs.
…o states

The admin wasn't clearing `address.state_id` from the DB when you switched from
a country with states to a country without states.  You would then end up with
an address with both `state_name` and `state_id`, and `state_text` would end up
showing the old `state_id`.

This happened because we have the complicated state_name + state_id situation
with addresses, and we swap out one form input with another depending on the
country.

We needed to provide default hidden inputs for state_name and state_id with
blank values.
Copy link
Contributor

@jhawthorn jhawthorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jhawthorn jhawthorn merged commit 82d8a5a into solidusio:master Nov 15, 2017
kennyadsl added a commit to nebulab/solidus that referenced this pull request Nov 30, 2017
Saving an address with a country without states, after saving an
address that instead has states will raise a validation error, since
we are not resetting the state. We always had this issue, it's just
raising after solidusio#2371, which describe the same issue but for backend.

This commit fixes this problem by adding hidden fields that reset
state_id and/or state_name if they are disabled (via js).
kennyadsl added a commit to nebulab/solidus that referenced this pull request May 3, 2018
Saving an address with a country without states, after saving an
address that instead has states will raise a validation error, since
we are not resetting the state. We always had this issue, it's just
raising after solidusio#2371, which describe the same issue but for backend.

This commit fixes this problem by adding hidden fields that reset
state_id and/or state_name if they are disabled (via js).
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.

2 participants