Has the syntax for using misc/collapse.js on a Drupal page changed D6 > D7? I can no longer get this feature to work. I've tried both adding and omitting the drupal_add_js('misc/collapse.js') statement, as well as switching to the default Bartik theme both with and without the add_js statement.

My legends do appear, but they are not clickable. Syntax I'm using:

<fieldset class="collapsible collapsed"><legend>Click to expand</legend>Some text here.</fieldset>

I've also tried enclosing "Some text here" in a div: <div class="fieldset-wrapper">.

Any help would be appreciated.

Comments

m.e.’s picture

Anyone know?

m.e.’s picture

After much reading and experimenting I learned that in D7 collapsible fieldsets need a different "add" statement:

drupal_add_library('system', 'drupal.collapse');

Posting here in case anyone else had this problem.

aburrows’s picture

If its custom code in a module then you can define it using field api

$form['contact'] = array(
  '#type' => 'fieldset',
  '#title' => t('Contact settings'),
  '#weight' => 5,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
);