So there exists a snippet here:
I was going tor reuse this, but when I declare this in my forms.py, and I render the html..
submit_button = SubmitButtonField()
value is not supplied (it’s escaped to string None), while name is default to submit_button, probably because of the forms.Widget constructor.
How can I supply the name and the value? I tried to write an init method for the widget…
def __init__(self, name, value, label, attrs):
print '%s, %s, %s, %s' %(name, value, label, attrs)
self.name, self.value,self.label = name, value, label
self.attrs = attrs
But this doesn’t quite make sense if the field is always (supposedly) default to use the widget SubmitButtonWidget… instead I should supply these values in the field init method. But it doesn’t allow me to do.
How should I rewrite this snippet so it can accept my supplied values?
As written in the comment at the very top of the snippet, the usage is
Your missing value comes from the
initialkeyword argument. The name is the name of the form field.