[英]Drupal hook_form_alter weight control
嘗試在新內容類型添加表單中添加一些其他表單項。
同時嘗試增加提交和預覽的權重。
function mymodule_form_alter(&$form, &$form_state, $form_id){
//add some $form items here
$form['actions']['submit']['#weight'] = 2000;
$form['actions']['preview']['#weight'] = 2001;
}
但不知何故,提交和預覽按鈕仍然在那里添加的新項目之上。
嘗試將#weight
屬性添加到$form['actions']
包裝器中。
您當前的代碼會更改actions wrapper
內2個按鈕的權重,並且不會影響包裝器的重量。
例如,請參閱以下代碼:
function mymodule_form_alter(&$form, &$form_state, $form_id)
{
//add some $form items here
$form['actions']['#weight'] = 2000;
}
希望這有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.