The module, attachments (http://drupal.org/project/attachments), had this problem but it can also be found in the Node Expire module (which is no longer being maintained but is the best of the node expiration modules) and it's bound to exist in other modules.
Drupal 7 note: This module is not required for Drupal 7 which has the "#attached" option which is far more versatile.
There are two ways of using this module:
- A developer can simply insert the necessary settings for the Stylistics module into their hook_form_alter(), instead of loading their JS and CSS files at that point and let the Stylistics module handle all the file loading whether first load, reload or on error;
- Create some override code which adds the JS and CSS files for some other modules but only to be loaded on form error (to avoid problems with JS settings being loaded twice);
How it works
The Stylistics module hooks into every form, adding a "pre_render" routine. In the pre_render routine it searches the whole form array looking for a "#stylistics" element (though normally this would probably be at the top level of the form structure). The structure of the "#stylistics" array looks like this:
$form['#stylistics'] = array( '<modulename>' => array( 'js' => array( <array of drupal_add_js() arguments>, <array of drupal_add_js() arguments>, ..., ); 'css' => array( <array of drupal_add_css() arguments>, <array of drupal_add_css() arguments>, ..., ); 'js_skip' => array( <array of drupal_add_js() arguments>, <array of drupal_add_js() arguments>, ..., ); ), 'jquery_ui' => array( <name of jquery_ui package>, <name of jquery_ui package>, ..., ); );
So rather than using:
drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js); drupal_add_css(drupal_get_path('module', 'mymodule') . '/mymodule.css);
You would use:
$form['#stylistics']['mymodule']['js'] = array(drupal_get_path('module', 'mymodule') . '/mymodule.js); $form['#stylistics']['mymodule']['css'] = array(drupal_get_path('module', 'mymodule') . '/mymodule.css);
Other people's modules
Work on this module was facilitated by the Workshop.
- Maintenance status: Minimally maintained
- Development status: Maintenance fixes only
- Reported installs: 90 sites currently report using this module. View usage statistics.
- Downloads: 1,722
- Last modified: December 1, 2014
- Stable releases are covered by the security advisory policy.
Look for the shield icon below.