0

I have these errors :

  • Notice: Undefined index: #attributes in theme_container() (line 3251 of /Applications/MAMP/htdocs/drupal-7.22/includes/form.inc).
  • Recoverable fatal error: Argument 1 passed to drupal_attributes() must be of the type array, null given, called in /Applications/MAMP/htdocs/drupal-7.22/includes/form.inc on line 3251 and defined in drupal_attributes() (line 2374 of /Applications/MAMP/htdocs/drupal-7.22/includes/common.inc).

And I do not understand why since I checked on other similar posts and my code seems ok :

.module file :

function gestion_videos_menu() {
 $items = array();

 $items['admin/config/media/gestionvideos'] = array(
 'title' => 'Gestion vidéos',
 'description' => 'Configurer le plugin VOD Infomaniak',
 'page callback' => 'drupal_get_form',
 'page arguments' => array('gestionvideos_configuration'),
 'file' => 'gestion_videos.admin.inc',
 'access arguments' => array('administer site configuration'),
 'type' => MENU_NORMAL_ITEM,
 );
return $items;
}

and .admin.inc file:

function gestionvideos_configuration() {
  $form = array(
    '#submit' => array('gestionvideos_configuration_submit'),
  );
  $form['config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Administration du plugin VOD'),
    '#description' => t('Pour fonctionner, le plugin a besoin de s\'interfacer avec votre compte VOD infomaniak.<br/>
                    Pour des raisons de securites, il est fortement conseille de creer un nouvel utilisateur dedie dans votre admin infomaniak avec uniquement des droits restreints sur l\'API.<br/>
                    Pour plus d\'information, veuillez vous rendre dans la partie "Configuration -> Api & Callback" de votre administration VOD.  
                '),
  );
  return system_settings_form($form);
}

Do you have any idea how I could solve this ? Thanks a lot !

2

You need to accept the $form (and $form_state) parameters as part of the function signature, and not overwrite the form, rather add to it:

function gestionvideos_configuration($form, &$form_state) {
  $form['#submit'][] = 'gestionvideos_configuration_submit';

  $form['config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Administration du plugin VOD'),
    '#description' => t('Pour fonctionner, le plugin a besoin de s\'interfacer avec votre compte VOD infomaniak.<br/>
                Pour des raisons de securites, il est fortement conseille de creer un nouvel utilisateur dedie dans votre admin infomaniak avec uniquement des droits restreints sur l\'API.<br/>
                Pour plus d\'information, veuillez vous rendre dans la partie "Configuration -> Api & Callback" de votre administration VOD.  
    '),
    '#default_value' => variable_get('config', ''),
  );

  return system_settings_form($form);
}

Choosing a different name than 'config' for your variable might also be wise. It's always preferable to provide a pseudo-namespace to variables as a prefix, usually the module name (e.g. gestionvideos_config). Don't forget to add the default value as in the above example as well, otherwise next time you go to the form it will have forgotten your config option.

If the above doesn't work for whatever reason, then the bug is somewhere else; try systematically disabling custom/contrib modules until you find the culprit.

  • Thanks you for your answer ! but I have now the error : Warning: Missing argument 1 for gestionvideos_configuration() in gestionvideos_configuration() (line 7 of /Applications/MAMP/htdocs/drupal-7.22/modules/gestion_videos/gestion_videos.admin.inc). Warning: Missing argument 2 for gestionvideos_configuration() in gestionvideos_configuration() (line 7 of /Applications/MAMP/htdocs/drupal-7.22/modules/gestion_videos/gestion_videos.admin.inc). – lightalex Jun 11 '13 at 10:49

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.