Zack
unread,Feb 24, 2008, 12:21:00 AM2/24/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
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.