How to hide empty fieldset, but leave prefix and suffix in place? Simple as this - I have a Form API fieldset with dynamically changing content. When it's empty, I don't want to show it at all. I use #prefix and #suffix to generate div my AJAX works with.

When I use:

$fieldset['#access'] = FALSE;


it disappears with it's div and no future AJAX call can make it reappear. So, how to hide it with empty, but leave wrapper intact?
The easiest way would be to wrap the fieldset itself in another element.

$fieldset_wrapper = array(
  '#prefix' =&gt; '&lt;div class="wrapper"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);

$fieldset_wrapper['fieldset'] = array(
  '#type' =&gt; 'fieldset',
  '#access' =&gt; FALSE,
);


As you might expect, setting #access to false will prevent an element from being rendered at all.