Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ A form widget is available for displaying radio buttons as a Bootstrap 5 button
RadioSelectButtonGroup
~~~~~~~~~~~~~~~~~~~~~~

*Known issue: This widget currently renders as a regular Bootstrap 5 RadioSelect.*

This renders a form ChoiceField as a Bootstrap 5 button group in the `primary` Bootstrap 5 color.

.. code:: django
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<div{% if widget.attrs.id %} id="{{ widget.attrs.id }}"{% endif %} class="btn-group" role="group">
{% for group, options, index in widget.optgroups %}
{% for option in options %}
<input type="{{ option.type }}"
class="{{ widget.attrs.class|add:' btn-check' }}"
autocomplete="off"
name="{{ option.name }}"
id="{{ option.attrs.id }}"
{% if option.value != None %} value="{{ option.value|stringformat:'s' }}"
{% if option.attrs.checked %} checked="checked"{% endif %}{% endif %}
{% if widget.attrs.disabled %} disabled{% endif %}
{% if widget.required %} required{% endif %}>
<label class="btn btn-outline-primary" for="{{ option.attrs.id }}">{{ option.label }}</label>
{% endfor %}
{% endfor %}
{% load django_bootstrap5 %}
{% bootstrap_server_side_validation_class widget as server_side_validation_class %}
<div{% include "django/forms/widgets/attrs.html" %}>
<div class="btn-group" role="group">
{% for group, options, index in widget.optgroups %}
{% for option in options %}
<input type="{{ option.type }}"
class="{{ widget.attrs.class|add:' btn-check' }}"
autocomplete="off"
name="{{ option.name }}"
id="{{ option.attrs.id }}"
{% if option.value != None %} value="{{ option.value|stringformat:'s' }}"
{% if option.attrs.checked %} checked="checked"{% endif %}{% endif %}
{% if widget.attrs.disabled %} disabled{% endif %}
{% if widget.required %} required{% endif %}>
<label class="btn btn-outline-primary" for="{{ option.attrs.id }}">{{ option.label }}</label>
{% endfor %}
{% endfor %}
</div>
</div>
Loading