Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293683

collapsible fieldset problems with #prefix, #suffix, markup rendering

$
0
0

Putting markup in a form in a collapsible fieldset doesn't work well unless it's wrapped in a <p> or <div> (apparently). If I put just text, the text falls outside the collapsed region and still shows when the fieldset is collapsed.

Sample code:

<?php
function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (isset(
$form['#node']) && $form['#node']->type .'_node_form'== $form_id) {
   
$form['ggg'] = array(
     
'#type'=> 'fieldset',
     
'#title'=> t('Test'),
     
'#collapsible'=> TRUE,
     
'#collapsed'=> TRUE,
     
'#tree'=> TRUE,
     
'#weight'=> -2,
    );   
   
$form['ggg']['node_type'] = array(
     
'#type'=> 'select',
     
'#title'=> t('Node type'),
     
'#options'=> node_get_types('names'),
     
'#suffix'=> 'hello!',
      );   
   
$form['ggg']['hoho'] = array(
     
'#value'=> 'hohoho',
      );
  }
}
?>

resulting HTML page source:

<fieldset class=" collapsible collapsed"><legend>Test</legend><div class="form-item" id="edit-ggg-node-type-wrapper">
<label for="edit-ggg-node-type">Node type: </label>
<select name="ggg[node_type]" class="form-select" id="edit-ggg-node-type"><option value="booo">Book page</option><option value="page">Page</option><option value="story">Story</option></select>
</div>
hello!hohoho</fieldset>

The problem may be this code in collapse.js:

.after($('<div class="fieldset-wrapper"></div>').append(fieldset.children(':not(legend)')));

but in mucking around, I haven't figured out how to make it work


Viewing all articles
Browse latest Browse all 293683

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>