我在我的模块中使用 Drupal 的 Forms API,并且尝试输出一个链接作为某些标记的一部分:
//$output = l('Result', 'document/1234');
$output = '<a href="document/1234">Result</a>';
$form['results'] = array(
'#type' => 'markup',
'#markup' => $output,
)
我尝试使用简单的字符串和 l() 函数,在这两种情况下,当页面呈现时,链接不起作用,并且当我检查元素时,它被破坏成这样:
<a href=" 1234"="" document="">
并且结束标签丢失了。
据我所知,在渲染标记之前,我没有对标记进行任何类型的后处理。
在我的模块的其他地方,我创建了这样的链接,并且它们正常输出。
有什么想法吗?
I'm using Drupal's Forms API in my module, and I'm attempting to output a link as part of some markup:
//$output = l('Result', 'document/1234');
$output = '<a href="document/1234">Result</a>';
$form['results'] = array(
'#type' => 'markup',
'#markup' => $output,
)
I've tried use both a simple string and the l() function and in both cases when the page is rendered, the link does not work, and when I inspect the element, it is mangled like this:
<a href=" 1234"="" document="">
and the closing tag is missing.
So far as I can see I'm not doing any post-processing of any kind on the markup before it is rendered.
In other places in my module I have created links like this and they are output normally.
Any ideas?
发布评论
评论(1)
这很奇怪,听起来好像另一个模块必须改变它......你有安装翻译/字符串替换模块吗?
这应该可以帮助您同时解决它,您可以使用渲染数组和
theme_link
输出如下链接:请注意,
attributes
中的html
是必需的键。That's very strange, it sounds like another module must be changing it...do you have translation/string replacement modules installed by any chance?
This should help you get it around it in the mean time, you can use render arrays and
theme_link
to output a link like this:Note that
html
inattributes
is a required key.