I want to upload the image as the background in the settings page of the zen theme.

In zen , It's easy to add an extra field in the theme-settings.php and it's worked at the single site system.

However,I want to add this feature to the domain access Website.

And I got some error message.

I just write the code as belowed:

$form['background_file'] = array(
    '#type'     => 'managed_file',
    '#title'    => t('Background'),
    '#required' => True,
    '#upload_location' => file_default_scheme() . '://theme/backgrounds/',
    '#default_value' => theme_get_setting('background_file'), 
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
  );

enter image description here

picture above appeared correct.

But when i push the upload button.

I got the error message belowed enter image description here

Notice: Undefined index: system_theme_settings in drupal_retrieve_form() (line 806 of /Library/WebServer/Documents/official/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'system_theme_settings' not found or invalid function name in drupal_retrieve_form() (line 841 of /Library/WebServer/Documents/official/includes/form.inc).
Notice: Undefined index: var in variable_realm_form_system_theme_settings_alter() (line 618 of /Library/WebServer/Documents/official/sites/all/modules/variable/variable_realm/variable_realm.module).
Notice: Undefined index: background_file in file_ajax_upload() (line 271 of /Library/WebServer/Documents/official/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /Library/WebServer/Documents/official/modules/file/file.module).

and i really don't know how to fix that.

I just referenced the content below and i can't find the answer.

Does someone fixed this situation before?

thanks a lot.

  • Working fine for me.. Where are you adding the code i mean in which file? – Sumit Madan Nov 19 '14 at 7:54
  • Looks like theme-settings.php – David Csonka Nov 19 '14 at 15:29
  • dammit! - works for me too. What is your Domain Access configuration looking like ? – jowan sebastian Nov 21 '14 at 19:59
  • Do you get these errors when you save the form without trying to upload an image ? – jowan sebastian Nov 24 '14 at 21:25

The form needs to be able to find system_theme_settings() when getting rebuilt via ajax.

form_load_include($form_state, 'inc', 'system', 'system.admin'); inside of theme-settings.php hook_form_system_theme_settings_alter() should do the trick.

$form['theme_extra']=array(
    '#type'         => 'fieldset',
    '#title'        => 'Extra Image',
    '#description'  => 'Image Fieldset',
    '#collapsible'  => TRUE, 
    '#collapsed'    => FALSE,
    '#weight'       => -10,
  );     
$form['theme_extra']['background_file']=array(
        '#type'     => 'managed_file',
        '#title'    => 'test title',
        '#description' => 'description',
        '#required' => FALSE,
        '#upload_location' => file_default_scheme() . '://theme/backgrounds/',
        '#default_value' => theme_get_setting('background_file'), 
        '#upload_validators' => array(
          'file_validate_extensions' => array('gif png jpg jpeg'),
        ),
      );

This code !!

  • This is the actual answer... great job. – darol100 Jan 7 '16 at 11:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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