Tasks::getFormOptions

public Tasks::getFormOptions(array $database)

Return driver specific configuration options.

Parameters

$database: An array of driver specific configuration options.

Return value

The options form array.

File

core/lib/Drupal/Core/Database/Install/Tasks.php, line 204

Class

Tasks
Database installer structure.

Namespace

Drupal\Core\Database\Install

Code

public function getFormOptions(array $database) {
  $form['database'] = array(
    '#type' => 'textfield',
    '#title' => t('Database name'),
    '#default_value' => empty($database['database']) ? '' : $database['database'],
    '#size' => 45,
    '#required' => TRUE,
    '#states' => array(
      'required' => array(
        ':input[name=driver]' => array('value' => $this->pdoDriver),
      ),
    ),
  );

  $form['username'] = array(
    '#type' => 'textfield',
    '#title' => t('Database username'),
    '#default_value' => empty($database['username']) ? '' : $database['username'],
    '#size' => 45,
    '#required' => TRUE,
    '#states' => array(
      'required' => array(
        ':input[name=driver]' => array('value' => $this->pdoDriver),
      ),
    ),
  );

  $form['password'] = array(
    '#type' => 'password',
    '#title' => t('Database password'),
    '#default_value' => empty($database['password']) ? '' : $database['password'],
    '#required' => FALSE,
    '#size' => 45,
  );

  $form['advanced_options'] = array(
    '#type' => 'details',
    '#title' => t('Advanced options'),
    '#weight' => 10,
  );

  $profile = drupal_get_profile();
  $db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_';
  $form['advanced_options']['prefix'] = array(
    '#type' => 'textfield',
    '#title' => t('Table name prefix'),
    '#default_value' => empty($database['prefix']) ? '' : $database['prefix'],
    '#size' => 45,
    '#description' => t('If more than one application will be sharing this database, a unique table name prefix – such as %prefix – will prevent collisions.', array('%prefix' => $db_prefix)),
    '#weight' => 10,
  );

  $form['advanced_options']['host'] = array(
    '#type' => 'textfield',
    '#title' => t('Host'),
    '#default_value' => empty($database['host']) ? 'localhost' : $database['host'],
    '#size' => 45,
    // Hostnames can be 255 characters long.
    '#maxlength' => 255,
    '#required' => TRUE,
  );

  $form['advanced_options']['port'] = array(
    '#type' => 'number',
    '#title' => t('Port number'),
    '#default_value' => empty($database['port']) ? '' : $database['port'],
    '#min' => 0,
    '#max' => 65535,
  );

  return $form;
}
doc_Drupal
2016-10-29 09:46:22
Comments
Leave a Comment

Please login to continue.