I am working on a Zend form application where my form contains text boxes with watermarks.
we can achieve this in HTML by the following code:
<input type="text" placeholder="Search" name="q" />
My question is how to add the placeholder attribute in my input-box using Zend form ?
Here's an update for ZF2.
You'll have to use this in your Zend\Form\Form :
setAttrib
doesn't exists, butsetAttribute
does :But in
FormText
view-helper, you can't add options anymore, so you have to do :I know, this is an ugly hack !
It's already been mentioned to use:
You can also use it like this when extending Zend_Form
Or inside the view using Zend_View_Helper_FormText
My solution using jQuery
On Zend_Form_Element objects you can specify attributes:
I think you can call settAttrib() on your element like this when you define elements