Reputation: 13957
I'm trying to theme my Drupal site's user profile form at the moment. I'm using hook_form_alter in the theme's template.php file.
The code is the same as the code I've used to edit another form but for some reason I can't spot it's not working.
function THEME_NAME_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_profile_form') {
$form['current_pass']['#prefix'] = '<div class="loginFormBlock">';
$form['current_pass']['#suffix'] = '</div>';
$form['current_pass']['#size'] = '500';
//$form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/Login.png');
}
}
Now the commented out submit button part works when it's un commented but the current_pass bits don't do anything. Current_pass is the name of the field I'm trying to theme. THEME_NAME has been replaced by the theme's name.
ANSWER:
As suggested I looked into the $form array.
echo '<pre>';
print_r($form);
echo '</pre>';
Saw that current_pass was in the account array and amended the code to the following, which works fine.
$form['account']['current_pass']['#size'] = '500';
Hopefully this can help someone else.
Upvotes: 1
Views: 1992
Reputation: 700
I was just going to say same thing - do a dump of $form and make sure that the field actually exists - if it does and it still doesn't work then there may be another hook being called after yours and changing your changes.
ps: I am still using D6 but are you sure your putting your form_alter function in the right place? yours says THEME_NAME_form_alter - I know in D6 you have to put them in module layer not the theme layer (unless this has changed in D7???) - could this be your issue?
Upvotes: 2