I am using jquery accordion (v.1.8). When I use prefix for div creation id is missing i.e.
$form['container'开发者_如何学编程] = array(
'#prefix' => '<div>',
'#attributes' => array('id' => 'accordion'),
'#suffix' => '</div>'
);
I cant see any id = "accordion" in DOM plus if I use this method below:
$form['container'] = array(
'#prefix' => '<div id = "accordion">',
'#value' => t('&nbps;'),
'#suffix' => '</div>'
);
it works can you please tell me the reason since am new to drupal
That's because Drupal is looking for some form element to add the id to but none are found. For instance, if you make #type
a fieldset as in below, the fieldset will have an id of "accordian".
$form['container'] = array(
'#type' => 'fieldset',
'#prefix' => '<div>',
'#attributes' => array('id' => 'accordion'),
'#suffix' => '</div>',
);
The code above will output a DIV that contains a fieldset with an id of "accordian". From there you could add other form elements inside the fieldset, like:
$form['container']['fake'] = array(
'#type' => 'textfield',
'#title' => t('My Textfield'),
'#size' => 30,
'#maxlength' => 128,
'#required' => TRUE,
);
For more information about Drupal forms, see the Forms API Reference, it is an extremely valuable source information.
精彩评论