I use Rubik as an admin theme. I have Open Publish as the default/frontend theme. When I submit a node/edit form that's missing a required field, the error message about the required field is shown on the default/frontend theme. It looks like total crap because the frontend theme is not styled for the node/edit form. I would like to keep the form validation errors on the administration theme. How can this be done?

I have tried:

  • Ajax module does the job perfectly, but it causes duplicate nodes when a new node is submitted on my site.
  • Clientside Validation module is almost good, but it "misses" some required fields (hierarchical select and cck node reference fields).

The only way to fix the problem is of course to make the "default" theme the administration theme as well. Even though that is ridiculous, it proves that Drupal will always pick the default theme for the form validation error messages. I'm sure this can be changed. I'm sure other people have been annoyed with this as well - those of us who use administration themes.

Comments

jrstmartin’s picture

Oh dang, what's with all this spam pushing by post down! :) (Not kidding) bump.

jrstmartin’s picture

Found a fix to this highly annoying and unsightly problem. This is assuming you have an admin theme set and hence variable_get('admin_theme', 0);. You can also do $custom_theme = 'theme_name_here';

/**
* Implementation of hook_init().
*
* This forces the admin theme on node add/edit form validation errors.
* Needs to have a module weight of 0 to work (default). 
*/
function glue_two_init() {
  global $custom_theme;

  if (arg(0) == 'node' && ((arg(1) == 'add') || (arg(2) == 'edit' ))) {
      $custom_theme = variable_get('admin_theme', 0);
      init_theme();
  }
}

Many thanks to subu.purohit for posting a fix.