php - Drupal changing links


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?




That's very strange, it sounds like another module must be changing 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 to output a link like this:

$form['results'] = array(
  '#theme' => 'link',
  '#text' => 'Result',
  '#href' => 'document/1234',
  '#options' => array(
    'attributes' => array('class' => array('cool-class'), 'id' => 'cool-id'),
      'html' => FALSE,

Note thathtml inattributes is a required key.

People are also looking for solutions to the problem: php - Repcached (failover doesn't seem to work)


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.