Hi
I'm using omega. I've already created a subtheme and customizing the theme setting form. I need to add a file upload field with the code below :

$form['theme_settings']['background_file'] = array(
    '#type'     => 'managed_file',
    '#title'    => t('Background'),
    '#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'),
    ),
  );

The form displays the field but on submit, i got the following error :
Fatal error: Call to undefined function omega_extension_development_settings_form_submit() in /xxx/drupal/includes/form.inc on line 1465

Comments

fubhy’s picture

Title: Add FILE field in omega setting form via theme-setting.php » Form state missing references to included files from extensions.

Ok, patch incoming.

fubhy’s picture

Status: Active » Needs review
StatusFileSize
new965 bytes

Please test if this patch fixes your problem.

mouhammed’s picture

fubhy’s picture

No need to re-queue. It's green :)

mouhammed’s picture

Thanks a lot for this patch.
It seem that the reference is duplicated. After adding the the patch and tested, I got this error message :
Fatal error: require_once(): Failed opening required '/path-to-web-directory/drupal//path-to-web-directory/drupal/profiles/recruiter/themes/omega/omega/template.php' (include_path='.:/usr/share/php:/usr/share/pear') in /path-to-web-directory/drupal/includes/form.inc on line 515
The patch doesn't fixes the problem.

malcolm_p’s picture

Removing the DRUPAL_ROOT from the $filename removes the above error for me.

damienmckenna’s picture

Version: 7.x-4.0-rc1 » 7.x-4.x-dev
Issue tags: -theme

I believe the problem persists in 4.x-dev, and there's no need to tag the issue "theme", that's kinda a given ;-)

robynlgreen’s picture

I ran into this bug today, following guidance from a core managed_file issue here: https://www.drupal.org/node/1862892

The patch in #2 worked, following the advice from #6 and not using DRUPAL_ROOT. I wasn't sure if it was safe to remove this from the file_exists() and require scope, so I prepared an updated patch with a new variable inside the conditional for form_state. It could be a bit cleaner if we could removed DRUPAL_ROOT from $filename, but the scope of that is a bit deeper than what I was testing against here so I'd have to defer on that to someone more involved.

Needs review, but this worked for my local and production build.