I have the following:
class MyDateSearchWidget(forms.MultiWidget):
def __init__(self, *args, **kwargs):
widgets = (
JsDateWidget(attrs={'class': 'jsDateField', 'size': '10',
'style':'width:12em;', 'localized':True}),
forms.HiddenInput(attrs={'value' : 'date'}),
forms.Select(choices=[('none',''), ('before',_('Before')),
('after',_('After')), ('passed',_('Has passed')), ('not_passed',_('Has
not passed'))])
)
super(MyDateSearchWidget, self).__init__(widgets, *args,
**kwargs)
def decompress(self, value):
if value:
return [value, 'date', value]
return [None, None, None]
class MyDateSearchField(forms.MultiValueField):
def __init__(self, *args, **kwargs):
fields = (
forms.DateField(),
forms.HiddenInput(),
forms.Select()
)
super(MyDateSearchField, self).__init__(fields, *args,
**kwargs)
def compress(self, data_list):
if data_list:
return data_list0, data_list1, data_list2
return None
I'm then creating a MyDateSearchField with following parameters:
MyDateSearchField(MyDateSearchWidget(), label='My label')
Question: how can I from the above call set initial values on the date
and select fields?
I've tried setting initial=['2011/02/10', 'before'] but this only sets
the date and ignores the other one.
Any advice is much appreciated.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.