2012-03-21 8 views
0

私は、入力テキストの背後にあるいくつかのHTMLリンクを配置しようと、私はこのようにそれが気にいらないですやろう:Zend_Form入力テキストの後ろに<a>を入れる方法は?

$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 
        )); 

と私の質問は、私が<a></a>間気にいらを置くことができる方法ですか?

よろしく

+0

[AnyMarkup decorator](http://www.zfsnippets.com/snippets/view/id/62)を参照してください。 –

答えて

4

あなたがコールバックを使用する必要があなた自身デコレータを書くことをしたくない場合は、次の

$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スタイルのコールバックだが、あなたはあまりにもオールドスタイルを使用することができます。

+0

ありがとう、これは私が必要なものです! :) –

+0

http://stackoverflow.com/faq#howtoask - 回答を受け入れることについての段落があります - してください:]あなたと私は評判のポイントを取得します - http://stackoverflow.com/faq#reputation – vandalizmo

+0

ok :)ありがとう答えがたくさんあります:) –

関連する問題