Last active
December 12, 2015 04:49
-
-
Save juampynr/4717407 to your computer and use it in GitHub Desktop.
Populate username field with First name and Last name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Populate username | |
description = Populates username field | |
php = 5.1 | |
core = 7.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
Drupal.behaviors.popusername= { | |
attach: function (context, settings) { | |
$('#edit-field-first-name-und-0-value, #edit-field-last-name-und-0-value', context).keyup(function () { | |
$('#edit-name').val($('#edit-field-first-name-und-0-value').val() + $('#edit-field-last-name-und-0-value').val()); | |
}); | |
} | |
}; | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file popusername.module | |
* TODO: Enter file description here. | |
*/ | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function popusername_form_user_register_form_alter(&$form, &$form_state, $form_id) { | |
$form['#attached']['js'] = array( drupal_get_path('module', 'popusername') . '/popusername.js'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment