문제

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

도움이 되었습니까?

해결책

//Here is an example 

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

다른 팁

Use the #id property:

$form['foo'] = array(
  '#type' => 'textfield',
  '#title' => t('Bar'),
  '#id' => 'baz',
);

To ensure uniqueness you should probably use drupal_html_id() on the ID string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top