Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $form['#attached']['js'] = array('(function ($){$(document).ready(function() { $(".form-item-field-name input").focus()});})(jQuery);' => array( 'type' => 'inline'));
- function your_module_form_alter(&$form, &$form_state, $form_id) {
- if($form_id == 'my_form'){
- // Add JavaScript file
- $form['#attached']['js'] = array(drupal_get_path('module', 'your_module') . '/your_file.js');
- // Or for inline JavaScript
- $form['#attached']['js'] = array('/* some javascript here */' => array( 'type' => 'inline'));
- }
- }
- function HOOK_form_user_login_alter(&$form, &$form_state, $form_id) {
- //should also add JS focus code for iOS Safari
- $form['name']['#attributes'] = array('autofocus' => '');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement