0

i am creating a contact form in flask and i want to use html placeholder's in jinja2, how to use html placeholder's within jinja 2 ?

<form action="{{ url_for('contact_page') }}" class="col-md-6 mx-auto my-auto mt-3" method="POST">

{{ form.hidden_tag() }}

<p class="text-left">{{ form.name.label() }}</p>
{{ form.name(class="form-control mb-2") }}

<p class="text-left">{{ form.email.label() }}</p>
{{ form.email(class="form-control mb-2") }}

<p class="text-left">{{ form.subject.label() }}</p>
{{ form.subject(class="form-control mb-2") }}

<p class="text-left">{{ form.message.label() }}</p>
{{ form.message(class="form-control mb-3") }}

<div class="form-group">
{{ form.submit(class="btn btn-primary btn-round mt-4 ") }}
</div>
</form>
davidism
  • 110,080
  • 24
  • 357
  • 317
vatsalay
  • 409
  • 1
  • 5
  • 15

1 Answers1

6

According to the WTForms documentation you can use render_kw to pass extra attributes to the widget. Something like this, in your form declaration:

email = StringField('email', render_kw={"placeholder": "you@example.com"})
André Laszlo
  • 14,497
  • 3
  • 63
  • 75