I have created a form with an input field and a button in symfony2.
I want to set onfocus="if (this.value=='email') this.value = ''" onblur="if (this.value=='') this.value = 'email'"
in the input box, so it will display “email” and when the user clicks it will disappear. I know how to do this in html (inside the tag properties) but in twig all I have is {{ form_widget(form.email) }}
<form action="{{ path('newsletter_create') }}" method="post" {{ form_enctype(form) }} novalidate="novalidate">
<div class="">{{ form_widget(form.email) }}</div>
{{ form_row(form._token) }}
<button type="submit" class="emailSubmit btn" >Submit >></button>
</form>
Any ideas would be highly appreciated.
Just add these fields as
attrvalues. In your Twig: