Sfoglia il codice sorgente

Set size on wishlist line quantity form field

This doesn't actually work since there is an overriding CSS style.  When
issue #851 is resolved, this should start working.
master
David Winterbottom 12 anni fa
parent
commit
661baf5e28
1 ha cambiato i file con 11 aggiunte e 3 eliminazioni
  1. 11
    3
      oscar/apps/wishlists/forms.py

+ 11
- 3
oscar/apps/wishlists/forms.py Vedi File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 from django import forms
2
 from django import forms
3
 from django.db.models import get_model
3
 from django.db.models import get_model
4
-from django.forms.models import inlineformset_factory
4
+from django.forms.models import inlineformset_factory, fields_for_model
5
 
5
 
6
 WishList = get_model('wishlists', 'WishList')
6
 WishList = get_model('wishlists', 'WishList')
7
 Line = get_model('wishlists', 'Line')
7
 Line = get_model('wishlists', 'Line')
18
         fields = ('name', )
18
         fields = ('name', )
19
 
19
 
20
 
20
 
21
-LineFormset = inlineformset_factory(WishList, Line, fields=('quantity', ),
22
-                                    extra=0, can_delete=False)
21
+class WishListLineForm(forms.ModelForm):
22
+
23
+    def __init__(self, *args, **kwargs):
24
+        super(WishListLineForm, self).__init__(*args, **kwargs)
25
+        self.fields['quantity'].widget.attrs['size'] = 2
26
+
27
+
28
+LineFormset = inlineformset_factory(
29
+    WishList, Line, fields=('quantity', ), form=WishListLineForm,
30
+    extra=0, can_delete=False)

Loading…
Annulla
Salva