I would like Flask "SubmitField" to use
<button type="submit" title="Save this form"><span>Save</span></button>
Instead:
<input type="submit" title="Save this form" />
I print it in templates:
{{ field(class=css_class, title=field.description, **kwargs) }}
I assume that I need to somehow modify SubmitInput (the widget behind SubmitField), but I'm not sure how to do this, do I need to change __html __ () somehow?
EDIT:
from flask.ext.wtf import Required, Length, EqualTo, Field, TextInput from flask import Markup class InlineButtonWidget(object): html = """ <button type="submit" title="%s"><span>%s</span></button> """ def __init__(self, input_type='submit'): self.input_type = input_type def __call__(self, field, **kwargs): kwargs.setdefault('id', field.id) kwargs.setdefault('type', self.input_type) if 'value' not in kwargs: kwargs['value'] = field._value() return HTMLString(self.html % (field.name, field.label )) class InlineButton(Field): widget = InlineButtonWidget() def _value(self): if self.data: return u', '.join(self.data) else: return u'' class SignupForm(Form): name = TextField('Name', [Length(min=1, max=200)]) submit = InlineButton('sign up')
I want to be able to do this:
submit = InlineButton ({'name': 'submit', 'title': 'Register today for the prizes.', 'type': 'submitfieldtype', 'textInsideSpan': 'Save current work'})
source share