3

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.

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

2 Answers 2

2
+100

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.

2
$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 !!

1
  • This is the actual answer... great job. Commented Jan 7, 2016 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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