drupaldrupal-7drupal-fapi

How can I set ID attribute for drupal 7 form elements?


I want to set the ID attribute of an element of a form that I'm creating in a module using the form API.


Solution

  • //Here is an example 
    
    $form['name'] = array(
     '#type' => 'item',
     '#title' => t('Title'),
     '#attributes' => array(
        'id' => 'your-id',
     ),
    );