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

<?php
    $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%23" instead of "http://localhost:8082/admin/config/zoho/test#". Can someone please tell me how to fix this error? I'm desperate. :(

Comments

BlackyWhoElse’s picture

Just use the Fragment option for this and it should work

<?php

l

(t('My Anchor Link'), '', array(
 
'fragment' => '',
 
'external' => TRUE,
 
'attributes' => array(
   
'title' => 'Title here.'
 
),
));
?>

Until the server crashes you're doing it quite right

drupal_dev_2014’s picture

thanks. That works.