user2990084 user2990084 - 1 year ago 148
Python Question

Update text of submit button in wtforms

I have a form, that will be used for a new submit and updates. My question is about the text of the submit button. I want to change the text to New submit and to New update, depending on the situation. This is purely informative.

class Interview(Form):
submit = SubmitField('New submit')

If possible, i want to avoid create a new class, with exactly same fields, only because of the text of submit.

Answer Source

The correct way to do this with mixins:

class InterviewMixin():

class InterviewSubmit(Form, InterviewMixin):
    submit = SubmitField('New submit')

class InterviewUpdate(Form, InterviewMixin):
    submit = SubmitField('New update')