[drupal ] Hash character (#) automatically translated to "%23" when form is loaded

Hi, I want to add a link like this to a form

<a id="addButton" href="#" style="display: inline-block;"></a>

So I use this code

    $form['addButton'] = array(
        '#attributes' => array('style' => 'display: inline-block;'),
        '#type' => 'link',
        '#title' => t(''),
        '#href' => current_path() . "#",
        '#id' => 'addButton',
    );

The problem is, when I load the form, the link translated to “http://localhost:8082/admin/config/zoho/test[B]%23[/B]” instead of “http://localhost:8082/admin/config/zoho/test[I]#[/I]”. Can someone please tell me how to fix this error? :confused: I’m desperate. :frowning: I cannot test my other code because of this stupid bug.

Try putting %23 instead of the hash; something is rendering the # character to not be displayed properly, something like htmlentities. I don’t know drupal so I’m not sure where you would look for this issue.

I finally found out that using #markup can make it work :slight_smile: