I'm writing a custom installation profile/distribution and I want to pre-populate some fields in the 'Configure Site' form (/core/install.php). I have managed to prefill/preselect other fields like (Site name, Site email address and Default country) but cannot preselect the Default time zone field. This is the code I am using:

function mydistribution_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
  $form['site_information']['site_name']['#default_value'] = 'Dummy Site Name';
  $form['site_information']['site_mail']['#default_value'] = '[email protected]';
  $form['regional_settings']['site_default_country']['#default_value'] = 'DE';
  $form['regional_settings']['date_default_timezone']['#default_value'] = 'Europe/Berlin';

As you can see in the screenshot, I manage to change the Default country successfully, but not the Default time zone.

The "strange" thing though is that when I inspect the code, I can see that the correct timezone has been selected but the form displays London.

enter image description here

I'm based in the UK so I guess this is how London gets selected.

Does anyone know how to get this fixed? Thank you in advance!


1 Answer 1


Drupal adds some JS to detect the timezone (through core/misc/timezone.js). This is interfering with your code, but can be removed easily:


This removes the timezone-detect class from the <select>, stopping it from being processed by the JS.

  • Thank you so much Clive! That resolved my issue.
    – consuela
    Commented Apr 15, 2022 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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