سؤال

I want this result:

<a href="path/to/something">This is a link! <span>with a span inside!</span></a>


This renders a link:

$render = array(
  'link' => array(
    '#type' => 'link',
    '#title' => t("This is a link!"),
    '#href' => "path/to/something",
  ),
);


Why does this not render a span inside the link?

$render = array(
  'link' => array(
    '#type' => 'link',
    '#title' => t("This is a link!"),
    '#href' => "path/to/something",
    'span' => array(
      '#type' => 'markup',
      '#markup' => ' <span>with a span inside!</span>',
    ),
  ),
);


Thanks in advance!

هل كانت مفيدة؟

المحلول

Just adjust your code to be:

$render = array(
  'link' => array(
    '#type' => 'link',
    '#title' => "<span>" . t("This is a link!") . "</span>",
    '#href' => "path/to/something",
     '#options' => array(
        'html' => TRUE,
    )
  ),
);

Hope this works... Muhammad.

نصائح أخرى

For the #title property just put the span in it like this: '#title' => t("This is a link! with a span inside!")

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top