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.
Old question, but for anyone else coming across this, an alternative is to just set it from code before rendering the template:
if is_submit:
form.submit.label.text = 'New submit'
else:
form.submit.label.text = 'New update'
return render_template(...)
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With