Hello again,
I'm trying to fill a form with default values when there is one available in my table. In this case, one is definitely available.
Expected result is first name has "bob" pre-filled in the first name field. Actual result is the field is empty. I used the watchdog function to double check I was getting something back from my function and the correct value shows up in drupal's watchdog.
function cg_volunteer_form_alter(&$form, $form_state, $form_id) {
if ($form['#id'] == 'user-profile-form' || $form['#id'] == 'user_profile_form'
|| $form['#id'] == 'user-register-form' || $form['#id'] == 'user_register_form') {
//I force the entire thing on top with the weight -999
$def_usr_vals = cg_get_user_info ();
$cg_my_name = $def_usr_vals['cg_first_name'];
watchdog('cg_volunteer', 'cg in form_alter %dumb', array('%dumb' => $cg_my_name), WATCHDOG_NOTICE, $link = NULL);
$form['cg_first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#default' => $cg_my_name,
'#maxlength' => 50,
'#suffix' => '
',
);
}
};
function cg_get_user_info (){
global $user;
$cg_u_fn = db_select('cg_contacts', 'cginfo', array('cg_prefix', 'cg_first_name', 'cg_last_name', 'cg_address1', 'cg_address2', 'cg_city',
'cg_state', 'cg_zip_first5', 'cg_zip_last5', 'cg_phone1', 'cg_phone2'));