Hi,
If I have these custom field, widget, and form:
class PersonField(forms.MultiValueField):
def __init__(self, *args, **kwargs):
fields = (
forms.CharField(label='Title'),
forms.CharField(label='First name'),
forms.CharField(label='Middle initial'),
forms.CharField(label='Last name'),
forms.CharField(label='Suffix'),
forms.CharField(label='Credential')
)
widgets = PersonWidget()
super(PersonField, self).__init__(fields,
widget=widgets,
*args, **kwargs)
def compress(self, data_list):
return data_list
class PersonWidget(forms.widgets.MultiWidget):
def __init__(self):
widgets = (
forms.widgets.TextInput(),
forms.widgets.TextInput(),
forms.widgets.TextInput(),
forms.widgets.TextInput(),
forms.widgets.TextInput(),
forms.widgets.TextInput()
)
super(PersonWidget, self).__init__(widgets)
def decompress(self, value):
if value:
return value
return [None, None, None, None, None]
class TestPersonForm(forms.Form):
contact = PersonField(label='Contact Info')
Why doesn't
>>> f = TestPersonForm()
>>> f.as_p()
have labels generated for all the CharFields as defined in
PersonField?
I get the label for the PersonField ('Contact Info') but
none of the
labels for the subfields. Any help greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|