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

Custom MultiWidget not showing the picker icon #119

Open
claudep opened this issue Apr 29, 2024 · 0 comments
Open

Custom MultiWidget not showing the picker icon #119

claudep opened this issue Apr 29, 2024 · 0 comments

Comments

@claudep
Copy link
Contributor

claudep commented Apr 29, 2024

I have implemented a custom MultiWidget input like this:

from django import forms
from bootstrap_datepicker_plus.widgets import DatePickerInput, TimePickerInput

class PickDateTimeWidget(forms.SplitDateTimeWidget):
    def __init__(self, attrs=None):
        widgets = [DatePickerInput, TimePickerInput]
        forms.MultiWidget.__init__(self, widgets, attrs)

It used to work fine in DBDP 4, but in the latest version (5.0.5), the picker icons are not showing.

It looks like applying the following changes is solving the issue:

diff --git a/src/bootstrap_datepicker_plus/_base.py b/src/bootstrap_datepicker_plus/_base.py
index fdf07d1..c33e85f 100644
--- a/src/bootstrap_datepicker_plus/_base.py
+++ b/src/bootstrap_datepicker_plus/_base.py
@@ -78,7 +78,7 @@ class BasePickerInput(DateTimeBaseInput):
         """Return widget context dictionary."""
         settings = get_widget_settings()
         context = super().get_context(name, value, attrs)
-        context["addon_icon_class"] = settings.addon_icon_classes[self.variant]
+        context["widget"]["addon_icon_class"] = settings.addon_icon_classes[self.variant]
         return context
 
     @deprecated(
diff --git a/src/bootstrap_datepicker_plus/templates/bootstrap_datepicker_plus/input.html b/src/bootstrap_datepicker_plus/templates/bootstrap_datepicker_plus/input.html
index 23190c4..7ec0455 100644
--- a/src/bootstrap_datepicker_plus/templates/bootstrap_datepicker_plus/input.html
+++ b/src/bootstrap_datepicker_plus/templates/bootstrap_datepicker_plus/input.html
@@ -1,7 +1,7 @@
 <div class="input-group dbdp">
   {% include 'django/forms/widgets/text.html' %}
   <div class="input-group-addon input-group-append input-group-text">
-    <i class="{{ addon_icon_class }}"></i>
+    <i class="{{ widget.addon_icon_class }}"></i>
   </div>
 </div>
 {% if "data-dbdp-debug" in widget.attrs %}
claudep added a commit to claudep/django-bootstrap-datepicker-plus that referenced this issue May 14, 2024
claudep added a commit to claudep/django-bootstrap-datepicker-plus that referenced this issue May 14, 2024
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

No branches or pull requests

1 participant