2

Zend_Form_Elment の記述デコレータ内で HTML を使用することは可能ですか? たとえば、次のステートメントは機能しません。

$number = new Zend_Form_Element_Text('number', array(
       'size' => 32,
       'description' => 'Please the the following website: <a href="foo/bar">lorem ipsum</a>',
       'max_length' => 100,
       'label' => 'Number'));

リンクは説明に表示されません。括弧は対応する特殊文字に変換されます。

リンクを表示する (または HTML を使用する) 別の方法はありますか?

4

1 に答える 1

4

Description出力をエスケープしないようにデコレータに指示する必要があるだけです。

試す:

$number = new Zend_Form_Element_Text('number', array(
   'size'        => 32,
   'description' => 'Please the the following website: <a href="foo/bar">lorem ipsum</a>',
   'max_length'  => 100,
   'label'       => 'Number')
);

$number->getDecorator('Description')->setOption('escape', false);

要素に独自のデコレータ セットを作成する場合は、次のようにデコレータを構成するときにこのオプションを指定することもできます。

    $elementDecorators = array(
        'ViewHelper',
        'Errors',
        array('Description', array('class' => 'description', 'escape' => false)),
        array('HtmlTag',     array('class' => 'form-div')),
        array('Label',       array('class' => 'form-label', 'requiredSuffix' => '*'))
);

関連する部分は次のとおりです。

array('Description', array('class' => 'description', 'escape' => false )),

于 2012-07-10T17:22:22.193 に答える