Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By drupal_dev_2014 on
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%23" instead of "http://localhost:8082/admin/config/zoho/test#". Can someone please tell me how to fix this error? I'm desperate. :(
Comments
Just use the Fragment option
Just use the Fragment option for this and it should work
thanks. That works.
thanks. That works.