0

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

1 Answer 1

0

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() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.