0

After running a dpm($form) via hook_form_FORM_ID_alter I couldn't see the 'Local settings' in the form defintion of the user profile form. I did a search for 'locale settings' on all the code and found the value I need to alter (I think) on line 2016 of system.module. So I tried:

function MY_MODULE_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['timezone']['#collapsible'] == FALSE;
}

Cleared the cache. Fieldset is still collapsible?

2
  • Which version of drupal are you using?
    – Matt
    Jan 15 '14 at 13:29
  • I'm using Drupal 7. The error thrown is: Undefined index: timezone. I don't know what to alter. system.module alters the form on line 1967.
    – dbj44
    Jan 15 '14 at 13:41
1

Found it! The point is that your hook_form_alter is called before system_form_alter, so you don't see the timezone. You need to reorder the implementation of hooks with hook_module_implements_alter

Here is the full code:

function CUSTOM_MODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'form_alter') {
    $group = $implementations['CUSTOM_MODULE'];
    unset($implementations['CUSTOM_MODULE']);
    $implementations['CUSTOM_MODULE'] = $group;
  }
}

function CUSTOM_MODULE_form_user_profile_form_alter(&$form, &$form_state) {
  $form['timezone']['#collapsible'] = FALSE;
}

Credits to this post.

0

I know this doesn't precisely answer the question, but I just used this by itself in my theme's template.php with no problem:

function MY_THEME_form_user_profile_form_alter(&$form, &$form_state) {
  $form['timezone']['#collapsible'] = FALSE;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.