如何为drupal 7表单元素设置ID属性?
我想设置使用表单API在模块中创建的表单元素的如何为drupal 7表单元素设置ID属性?,drupal,drupal-7,drupal-fapi,Drupal,Drupal 7,Drupal Fapi,我想设置使用表单API在模块中创建的表单元素的ID属性。使用: //Here is an example $form['name'] = array( '#type' => 'item', '#title' => t('Title'), '#attributes' => array( 'id' => 'your-id', ), ); 为了确保唯一性,您可能应该在ID字符串上使用 $form['foo'] = array( '#type' =>
ID
属性。使用:
//Here is an example
$form['name'] = array(
'#type' => 'item',
'#title' => t('Title'),
'#attributes' => array(
'id' => 'your-id',
),
);
为了确保唯一性,您可能应该在ID字符串上使用
$form['foo'] = array(
'#type' => 'textfield',
'#title' => t('Bar'),
'#id' => 'baz',
);