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

Make the model/formfield region kwarg the default selection in PhoneNumberPrefixWidget #574

Closed
emdemir opened this issue Sep 18, 2023 · 1 comment · Fixed by #593
Closed

Comments

@emdemir
Copy link

emdemir commented Sep 18, 2023

Currently, the region value is passed from the model field to the form field, but it is not used after that. I wanted to make it so that the region value I added in the model field could be also used in the PhoneNumberPrefixWidget as the default region selected, so for example the customer would see their own country selected by default but then they could select another country for international numbers. Would this be an okay addition? Seems like this would simply entail setting self.widget.region = region in the formfield constructor. Alternatively we could pass it as part of the attrs dict, but that would require a custom BoundField subclass as sadly formfields cannot directly influence widget attrs.

I can create a PR if this is acceptable.

@francoisfreitag
Copy link
Collaborator

francoisfreitag commented Sep 18, 2023

That looks like a usability improvement, thanks for the suggestion! 👍

I see that the form field already passes the region to widgets that support it. It looks like RegionalPhoneNumberWidget relies on it, so the change will likely be quite small.

widget = self.widget(region=self.region)

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 a pull request may close this issue.

2 participants