2

I maintain a module (http://www.drupal.org/project/csm) that adds two tabs to the node type settings form at admin/structure/types/manage/{node-type}. I'd like to add some help text to these tabs. In the picture below, there is help text set for the top four tabs, but not for the last three tabs.

Screenshot of node type settings page

I've had a look at the Drupal core code to see if I can work out how to set this help text, but have had no joy so far. How can I set it?

For the record, the code used to generate the last tab in the form is as follows:

$form['cnpt'] = array(
  '#type' => 'fieldset',
  '#title' => t('Node creation page title and status message'),
  '#access' => user_access('change ' . $form['#node_type']->type . ' creation page title'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#group' => 'additional_settings',
  //'#tree' => TRUE,
  '#weight' => 101,
  '#attributes' => array('class' => array('csm-form')),
  );
1

The summaries are dynamic so they're controlled by JS. It should be something as simple as this:

(function($) {
  Drupal.behaviors.csmFieldsetSummaries = {
    attach: function (context) {
      $('fieldset.csm-form', context).drupalSetSummary(function (context) {
        // Make a decision about what summary to display based on your tab's current value.
        var summary = $('input.foo', context).is(':checked') ? 'Input checked' : 'Input not checked';      

        // Or static strings are fine too.
        summary = 'Static summary';

        return Drupal.t(summary);
      });

      $('fieldset.another-csm-form', context).drupalSetSummary(function (context) {
        // ...
      });
    }
  };
})(jQuery);
1
  • Superb, thank you so much! I should add, for anyone who finds this useful, that I also had to add '#attached' => array('js'=>array(drupal_get_path('module', 'csm') . '/csm.js'),), to $form['cnpt'] so the form went off to find csm.js (where I put the JS you've written) :) – Jim Nov 27 '15 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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