我正在开发一个zendframework项目。我的注册页面包含一个“我同意使用条款”字段,旁边有一个复选框。这里我想把“使用条款”作为链接。但我是zend和PHP5的新手。我检查了代码,下面是显示“我同意使用条款”的代码。
'Agree' => array ('Checkbox', array (
'Required' => true,
'Decorators' => $element Decorators,
'Label' => 'I Agree to the Terms of Use',
)),我如何将使用条款作为链接?
发布于 2011-03-01 17:45:19
如果正确设置了标签装饰器,则可以将HTML添加到标签。首先,将'escape' => false添加到标签装饰器的选项中。如果没有看到确切的装饰器,就很难确切地说出它应该是什么样子,但它很可能看起来像这样:
$elementDecorators = array(
// some decorators...
array('Label',
array('placement' => 'prepend',
'escape' => false)),
// other decorators...
);然后,将HTML锚添加到您的标签:
'Label' => 'I Agree to the <a href="/terms-of-use/">Terms of Use</a>', 不过,在标签上放置链接时要小心。标签的本机单击操作是将焦点带到与其关联的输入。如果您在这方面有问题,您可以将相同的选项应用于Description装饰器,并在那里添加链接。
发布于 2013-05-25 00:10:16
您也可以通过以下方式完成此操作:
$radioElement = new Zend_Form_Element_Checkbox('formelement_0');
$radioElement->setLabel('Do you accept the <a href="#">Terms & Conditions</a>?');
$radioElement->getDecorator('Label')->setOption('escape', false);发布于 2011-03-01 17:34:57
我对这个框架一无所知,只是猜测...
'Label' => 'I Agree to the <a href="/terms.pdf">Terms of Use</a>', https://stackoverflow.com/questions/5152601
复制相似问题