Reputation: 11
How can I position "101010" next to the first label, blue position, using wtf.quick_form()?
enter image description here enter image description here
**expectation: ** enter image description here
I have done: I changed the position of {{ 101010 }} but the value is not on the first line
Upvotes: 0
Views: 53
Reputation: 8046
You can change the label text at runtime.
@app.route("/")
def hello_world():
_form = RateMovieForm()
# Assign your label text at runtime
_value = "101010"
_form.rating.label.text = f"Your rating out of 10 e.g. {_value}"
return render_template('hello.html', form=_form)
Example code showing html output of label and input elements:
from wtforms.fields import FloatField
from wtforms.form import Form
class TestForm(Form):
rating = FloatField(label="Your rating out of 10 e.g.")
def test_form():
_form = TestForm()
_label = _form.rating.label() # get the generated label html
_input = _form.rating() # get the generated input html
print(_label)
print(_input)
# Assign your label text at runtime,
_value = "101010"
_form.rating.label.text = f"Your rating out of 10 e.g. {_value}"
_label = _form.rating.label() # get the generated label html
_input = _form.rating() # get the generated input html
print(_label)
print(_input)
if __name__ == "__main__":
test_form()
Upvotes: 0