I'm working on upgrading the Discussthis module and having a very frustrating time with the module settings. I've successfully got the settings to display in the standard D7 configuration page, and when I click on the title I get the settings form displayed, but with just one problem. Part of the settings have disappeared.
Here is what happens in D6 (as far as I can make out):
1) The discussthis_admin_settings() function is called, this puts together a series of fieldsets (three in fact). The first two contain straightforward checkboxes and input fields, the third is a bit more complex because it provides a checkbox for each node, and it wants to call its own theming function to render these, so right at the end of the function there is this:

$form['discussthis_forums']['#theme'] = 'discussthis_admin_settings_forums';
return systems_settings_form($form);

2) The discussthis_admin_settings_forums function gets called with a parameter "$variables", and this is supposed to do some special rendering on the checkboxes of the last fieldset. It expects $variables (as far as I can see) basically to contain the $form that was passed back by the previous form.

In D6 this all works fine. In D7 everything works, except that now the $variables parameter contains nothing but this:
Array ( [0] => form )
So somewhere along the line, I have lost the variables that were previously in $form. Something has changed in D7, but I would appreciate if someone could tell me what!

Comments

jaypan’s picture

It sounds like your implementation of hook_theme() may be the problem. Can't tell without code though.

Contact me to contract me for D7 -> D10/11 migrations.

joel_guesclin’s picture

Here is the code for the hook_theme function. It doesn't seem to do anything much...

function discussthis_theme() {
  return array(
    'discussthis_admin_settings_forums' => array(
      'variables' => array('form'),
      'file' => 'discussthis.admin.inc',
    ),
  );
}
nevets’s picture

From http://api.drupal.org/api/drupal/modules!system!system.api.php/function/..., 'variables' => array('form'), should probably be 'render element' => 'form',

joel_guesclin’s picture

What seems to have changed between D6 and D7 is that whereas in D6 the parameter passed to the function defined under "#theme" was the $form itself, in D7 it is the variables defined in the hook_theme function. I have no idea why this should be though

jaypan’s picture

Actually nevets gave you the correct answer above.

Contact me to contract me for D7 -> D10/11 migrations.

joel_guesclin’s picture

I confess I still don't quite understand how, but it did.
Though I did waste a fair bit of time until I remembered to clear cache all. I'm used to playing in D6 and having the registry rebuilt on every page when in development, but that option seems to have disappeared in D7.