欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal form drupal_get_form 增加link href 链接 有大用

shiping1 的头像

添加文本文字也是用markup 
见 /node-admin/2141

How to add custom link to drupal form / navigation using form hook



在 drupal6 中
function modulename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'your_form_id') {  
    $form['navigation']['anyname'] = array ( '#type' => 'markup','#value' => '<a href="#">My Custom Link</a>' );
  }
}


在 drupal7 中

In Drupal 7 you can use #markup attribute, as suggested by MOLOT


/**
 * Implements hook_form_alter()
 */
function hook_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_login':
    case 'user_login_block':
      $form['link'] = array('#markup' => l(t('Link text'),'node'));
      break;
  }
}

普通分类: