How can some Javascript or CSS be used to keep a field set open when the page is refreshed?

I am using a module with a form in a fieldset that is automatically closed whenever the page is opened or refreshed. I don't want to touch the module code or write a module to fix it. Is there some Javascript or CSS that can be used to fix it, ie like CSS Injector or Javascript injector?

2 Answers 2


You could definitely do that with some custom JS, but it might not be worth the trouble as there's a pre-built module which does what you need:

Fieldset collapser

Whenever a user clicks on a collapsible fieldset header to toggle the "collapsed" state, the new state is being saved - uniquely for every form fieldset possible. Depending on the user's being registered with your site or not, this happens either in his user account data or locally on his computer using cookies.

When the same form is called the next time, the fieldset states are restored to what they were last time. For registered users, this happens already on your server while preparing the form. Anonymous users will still see a little form animation by an invisible hand but then also be happy with their favorite fieldset states.


You should use hook_form_alter() and assign FALSE to #collapsed on the fieldset element.

Please read the Form API documentation for more details.

BTW, I love @Clive's answer more.

  • I want to avoid any module coding, and use stuff in the admin which gets backuped with the database.
    – vfclists
    Commented Jul 6, 2016 at 17:53
  • @Clive's answer suits for you :)
    – Jimmy Ko
    Commented Jul 6, 2016 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.