Collapsible fieldsets in form using button How can I make a button collapse a fieldset in my custom form? I tried the following which did not seem to work:

$form['stepone']['next'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; t('Next'),
    '#name' =&gt; 'nextone',
    '#weight' =&gt; 1, 
    '#submit' =&gt; array('collapse_next'),
    );


The function is:

function collapse_next($form, &amp;$form_state){
    if(isset($form_state['values']['nextone'])){
    $form['stepone']['#collapsed'] = TRUE;
    $form['steptwo']['image']['#collapsed'] = FALSE;
    return $form;       
    }
}
you may use jquery for this. give some id to your button and on button click trigger the default fieldset collase or use toggle to hide show fieldset. Hope this help!