占位符文本在zend文本元素中 [英] placeholder text in zend text element
本文介绍了占位符文本在zend文本元素中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以通过以下代码在HTML中实现这一点:
< input type =textplaceholder =Searchname =q/>
我的问题是如何使用Zend表单在我的输入框中添加占位符属性?
<$> p $ p>
$ element-> setAttrib('placeholder','Search');
在扩展Zend_Form时,您也可以像这样使用它
$ element = $ this-> createElement('text','q',array(
'placeholder'=>'搜索',
'label'=>'搜索'
));
或者在视图内使用Zend_View_Helper_FormText
echo $ this-> formText('q',null,array('placeholder'=>'Search'));
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'));
这篇关于占位符文本在zend文本元素中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文