Now field_ui.admin.inc attach CSS and JS directly with #attached.

615: $form['#attached']['css'][] = drupal_get_path('module', 'field_ui') . '/field_ui.css';
616: $form['#attached']['js'][] = drupal_get_path('module', 'field_ui') . '/field_ui.js';

This is a problem for jquery_update #1448494: jQuery 1.7: field_ui.js use attr for property we can not replace this file with hook_library_alter().

Should we make a form_alter or it will be more appropriate to add CSS and JS using hook_library and add_library?

Comments

gagarine’s picture

Category: feature » support

I finnaly end up using hook_js_alter https://drupal.org/node/1448494#comment-5767046 . But I will like if someone can tell me if it's ok.

/**
 * Implementation of hook_library_alter().
 */
function jquery_update_js_alter(&$javascript) {
  // Swap out jQuery to use an updated version of the library.
  $path = drupal_get_path('module', 'jquery_update');
  if (isset($javascript['modules/field_ui/field_ui.js'])) {
    $javascript['modules/field_ui/field_ui.js']['data'] = $path . '/replace/modules/field_ui/field_ui.js';
  }
}
nod_’s picture

That's exactly what this hook is for, so yes, it's ok.

field_ui is not really a library, that's the right way to do it.

gagarine’s picture

Status: Active » Closed (fixed)

Thanks

gagarine’s picture

Issue summary: View changes

Updated issue summary.