【问题标题】:Zend_Form how to put <a> behind input text?Zend_Form 如何将<a> 放在输入文本后面?
【发布时间】:2012-04-06 06:12:36
【问题描述】:

我尝试在输入文本后面放置一些 HTML 链接,并尝试这样做:

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

我的问题是如何在 &lt;a&gt;&lt;/a&gt; 之间添加一些东西?

最好的问候

【问题讨论】:

标签: zend-framework zend-form


【解决方案1】:

如果你不想编写自己的装饰器,你必须使用回调:

$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。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-12-06
  • 1970-01-01
  • 2011-09-02
  • 1970-01-01
  • 2011-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多