1 install.core.inc install_settings_form($form, &$form_state, &$install_state)

Form constructor for a form to configure and rewrite settings.php.

Parameters

$install_state: An array of information about the current installation state.

See also

install_settings_form_validate()

install_settings_form_submit()

Related topics

File

core/includes/install.core.inc, line 962
API functions for installing Backdrop.

Code

function install_settings_form($form, &$form_state, &$install_state) {
  global $databases;

  // Do not let Backdrop attempt to save this form to tempstore, since the
  // table itself won't exist yet.
  $form_state['no_cache'] = TRUE;

  backdrop_static_reset('conf_path');
  $settings_file = conf_path(FALSE) . '/settings.php';
  $database = isset($databases['default']['default']) ? $databases['default']['default'] : array();

  backdrop_set_title(st('Database configuration'));

  $form['driver'] = array(
    '#type' => 'hidden',
    '#required' => TRUE,
    '#value' => !empty($database['driver']) ? $database['driver'] : 'mysql',
  );

  $driver = backdrop_load_database_driver();

  // Add driver specific configuration options.
  $form['driver']['#options']['mysql'] = $driver->name();
  $form['settings']['mysql'] = $driver->getFormOptions($database);
  $form['settings']['mysql']['#prefix'] = '<h2 class="js-hide">' . st('@driver_name settings', array('@driver_name' => $driver->name())) . '</h2>';
  $form['settings']['mysql']['#type'] = 'container';
  $form['settings']['mysql']['#tree'] = TRUE;
  $form['settings']['mysql']['advanced_options']['#parents'] = array('mysql');
  // For this exceptional situation, maintain the database password even on
  // form validation errors.
  if (isset($form_state['input']['mysql']['password'])) {
    $form['settings']['mysql']['password']['#attributes']['value'] = $form_state['input']['mysql']['password'];
  }

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => st('Save and continue'),
    '#limit_validation_errors' => array(
      array('driver'),
      array(isset($form_state['input']['driver']) ? $form_state['input']['driver'] : 'mysql'),
    ),
    '#submit' => array('install_settings_form_submit'),
  );

  $form['errors'] = array();
  $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);

  return $form;
}