-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix #7722. #7882
base: master
Are you sure you want to change the base?
Fix #7722. #7882
Conversation
Thanks for working on this. Having a look over, I'm wondering about the alternative of not introducing a new template, and using the existing "select.html" template. |
Render BooleanFields with allow_null=True as HTML select rather than as HTML checkbox in Browsable API encode#7722.
5e2b339
to
5c9bd01
Compare
Hi @tomchristie , <select class="form-control" name="{{ field.name }}">
{% if field.allow_null or field.allow_blank %}
<option value="" {% if not field.value %}selected{% endif %}>--------</option>
{% endif %}
</select> |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please rebase and make it merge able again, please
rest_framework/templates/rest_framework/horizontal/select_boolean.html
Outdated
Show resolved
Hide resolved
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Could the PR title have some words in it to describe the bug or the fix? Would help all of us looking at notifications or lists of tickets. Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
we might need a new taker for this |
Render BooleanFields with allow_null=True as HTML select rather than as
HTML checkbox in Browsable API #7722.
Description
This PR is created in order to fix issue #7722. A serializer field of type
BooleanField
withallow_null=True
was being rendered as HTML checkbox elements on Browsable API forms even though three values (True, False, and None/null) are possible. It was also happening for the modelBooleanField
instances withallow_null=True
that are converted to serializerBooleanField
instances. In this PR, I worked on keeping the checkbox rendering forBooleanField
s withallow_null=False
while providing dropdown rendering (HTML select element) forBooleanField
s withallow_null=True
.fix #7722
refs #7722