如何设置Drupal 7表单元素的ID属性?

Uni*_*que 3 drupal drupal-7 drupal-fapi

我想设置ID使用表单API在模块中创建的表单元素的属性。

小智 5

//Here is an example 

$form['name'] = array(
 '#type' => 'item',
 '#title' => t('Title'),
 '#attributes' => array(
    'id' => 'your-id',
 ),
);
Run Code Online (Sandbox Code Playgroud)