Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为drupal 7表单元素设置ID属性?_Drupal_Drupal 7_Drupal Fapi - Fatal编程技术网

如何为drupal 7表单元素设置ID属性?

如何为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' =>

我想设置使用表单API在模块中创建的表单元素的
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',
);