I have created a fieldset (which groups a field collection). Because it has a few nested levels and many fields, I want it to be shown collapsed. I am trying this code but it does not work. The id is retrieved directly from the source code of the web browser. The fieldset is the top-level, and there are more fieldsets inside of it. The form is displayed in the Admin page, the node edit form. The field "field-seo-general" is a #container.
function hook_form_alter(&$form, &$form_state, $form_id){
if($form_id == "my_form"){
$form["field-seo-general"]['options']['attributes']["#collapsible"] = TRUE;
$form["field-seo-general"]['options']['attributes']["#collapsed"] = TRUE;
...
} // function
$form['field_seo_general']['attributes']['class'][] = 'collapsible';
etc. Edit: If that doesn't work, try taking out['options']['attributes']
in each line.