Zend_Form 如何放置<a>在输入文本后面? [英] Zend_Form how to put <a> behind input text?
本文介绍了Zend_Form 如何放置<a>在输入文本后面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在输入文本后面放置一些 HTML 链接,我尝试这样做:
I try to put some HTML link behind input text and I try to do it's somthing like this:
$aElements[$iKey] = $oName = new Zend_Form_Element_Text($aValue['newsletter_question_answer_id']);
$oName->addDecorator('HtmlTag', array(
'tag' => 'a',
'href'=>'http://some_url.html',
'placement' => Zend_Form_Decorator_Abstract::APPEND
));
and my question is how can I put somthing between <a>
and </a>
?
最好的问候
推荐答案
如果你不想写你自己的装饰器你必须使用回调:
If You don't want to write Your own decorator You have to use callback:
$element->addDecorator('Callback', array(
'callback' => function($content, $element, $options) {
Zend_Debug::dump($content, 'content'); //elements decorated so far
Zend_Debug::dump($element, 'element'); //current element
Zend_Debug::dump($options, 'options'); //other options
return "<a href=\"{$options['href']}\">{$options['label']}</a>";
},
'option' => 'value', //everything but 'callback' and 'placement' gets
//passed to callback as option
'href' => 'http://example.com',
'label' => 'Link!',
'placement' => Zend_Form_Decorator_Abstract::APPEND
));
当然是php5.3风格的回调,不过你也可以用oldstyle.
Ofcourse it's php5.3 style callback, but You can use oldstyle too.
这篇关于Zend_Form 如何放置<a>在输入文本后面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文