(issue) Individual elements now have the ability to define what JavaScript and cascading stylesheets are associated with them. This is stated in the #attached_js and #attached_css property.
Drupal 6.x:
<?php
function example_admin_settings() {
// Add example.admin.css
drupal_add_css(drupal_get_path('module', 'example') .'/example.admin.css');
// Add some inline JavaScript
drupal_add_js('alert("You are visiting the example form.");', 'inline');
// Add a JavaScript setting.
drupal_add_js(array('mymodule' => 'example'), 'setting');
$form['example'] = array(
'#type' => 'fieldset',
'#title' => t('Example');
);
return $form;
}
?>Drupal 7.x:
<?php
function example_admin_settings() {
$form['#attached_css'] = array(
// Add example.admin/css.
drupal_get_path('module', 'example') . '/example.admin.css'
),
$form['#attached_js'] = array(
// Add some inline JavaScript.
'alert("You are visiting the example form.");' => 'inline',
// Add a JavaScript setting. Note that when the key is a number, the 'data' property will be used.
array(
'data' => array('mymodule' => array(...)),
'type' => 'setting'
),
);
$form['example'] = array(
'#type' => 'fieldset',
'#title' => t('Example');
);
return $form;
}
?>
6 days 19 hours ago
1 week 8 hours ago
1 week 1 day ago
1 week 5 days ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 2 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago