Hi,

My custom submit handler not fire, when i use managed_file field, that means If i upload any image with the field then submit the form the custom submit handler not firing, Its works if i didn't use managed_file field in the system_theme_settings alter.

And also I am getting this warning in my recent log.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'integrity_settings_form_submit' not found or invalid function name in Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (line 116 of /home/leopathu/Public/drupal-8.0.0/core/lib/Drupal/Core/Form/FormSubmitter.php).

May be it would relate with this issue : https://www.drupal.org/node/1862892

Comments

leopathu created an issue. See original summary.

swentel’s picture

Priority: Critical » Normal
Status: Active » Closed (duplicate)

It seems exactly the same actually :)

A workaround is to use a form alter in a module.

junaidpv’s picture

There is a solution to this problem without having an extra module. We can add `.theme` file path manually to the list files to be loaded while form is processed.

/**
 * Implements hook_form_system_theme_settings_alter().
 */
function MY_THEME_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $theme_file = drupal_get_path('theme', 'MY_THEME') . '/MY_THEME.theme';
  $build_info = $form_state->getBuildInfo();
  if (!in_array($theme_file, $build_info['files'])) {
    $build_info['files'][] = $theme_file;
  }
  $form_state->setBuildInfo($build_info);

  $form['#submit'][] = 'MY_THEME_form_system_theme_settings_submit';
}

function MY_THEME_form_system_theme_settings_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  // TODO: Extra submssio logic.
  // This submit handler will be called before default submit handler for this form.
}

See this post to read explanations: http://kb.detlus.com/articles/drupal/drupal-8-use-custom-submit-handler-for-theme-settings-form/.

awolfey’s picture

Perfect. Thanks junaidpv.

wslstar’s picture

The above solution is perfect to fix this warning issue. Thank you very much!