function example_form_alter

Implementation of hook_form_alter().

Allows the profile to alter the site-configuration form. This is called through custom invocation, so $form_state is not populated.

File

external_documentation/developer/example.profile, line 326

Code

function example_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'install_configure') {
        // Here we can play with the site configuration form provided
        // by the installer, by changing the prepopulated $form array.
        // See install_configure_form() inside install.php for its
        // default content.
        // Set default for site name field.
        $form['site_information']['site_name']['#default_value'] = 'Drupal example';
        // Set default for administrator account name.
        $form['admin_account']['account']['name']['#default_value'] = 'admin';
        // Remove the timezone setting, as this profile is supposed to be
        // focused on Czech language as an example, where the timezone is
        // obvious.
        unset($form['server_settings']['date_default_timezone']);
        // Define the timezone as fixed value instead, so that the submit
        // handler of the site configuration form may still process it.
        $form['date_default_timezone'] = array(
            '#type' => 'value',
            '#value' => '3600',
        );
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.