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 ?
It's already been mentioned to use:
$element->setAttrib('placeholder', 'Search');
You can also use it like this when extending Zend_Form
$element = $this->createElement('text', 'q', array(
'placeholder' => 'Search',
'label' => 'Search'
));
Or inside the view using Zend_View_Helper_FormText
echo $this->formText('q',null, array('placeholder' => 'Search'));