-
Notifications
You must be signed in to change notification settings - Fork 313
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
Question about accessing and styling the prefix and phone number field separately. #622
Comments
I think i have same issue. I am using SplitPhoneNumberField() but i want to set a custom bootstrap class in it. I didn't find any solution. If you found out the way please let me know. |
You can define custom fields as:
And then:
This way you just call it with the usual form syntax. I suggest using the package django-widget-tweaks that allows you to add classes quite easily. Your other option is to add the classes with Javascript by targeting the ID of the field as that is always the same, just F12 to find them. But I do not recommend this as it is very limiting. This implementation keeps you defining everything in the form. I just wish it was included in the package by default as these fields are just copied from their code. |
I have read the documentation and the issues that have been resolved, namely the #502, and cannot seem to figure it out. I want to access the prefix with the form in the context like so:
I understand that this is wrong and does not work, but was wondering if something like this is present or is it necessary to define a custom field for those specific widget to then style them. While using JS works for styling, it is a rather messy solution that I would like to avoid. I apologize if this has been answered somewhere else. I am a beginner and have just not uset multi value fields and widgets before. An example of how to separate these for styling without losing the validation process would be welcome. Thank you in advance.
The text was updated successfully, but these errors were encountered: