function _user_example_add_color_element
Helper function to add a "What is your favorite color?" dropdown to the user edit form.
Parameters
&$edit: The array of form values submitted by the user.
&$account: The user object who's form we are altering.
Return value
The form elements to add into the user edit form.
Related topics
1 call to _user_example_add_color_element()
- user_example_user in user_example/
user_example.module - Implementation of hook_user().
File
-
user_example/
user_example.module, line 105
Code
function _user_example_add_color_element(&$edit, &$account) {
$form = array();
$form['favorite_color'] = array(
'#type' => 'select',
'#title' => t('Favorite color'),
'#options' => array(
'red' => t('Red'),
'green' => t('Green'),
'blue' => t('Blue'),
'black' => t('Black'),
),
'#default_value' => !empty($account->favorite_color) ? $account->favorite_color : 'blue',
);
return $form;
}