function Tasks::getFormOptions
Same name in this branch
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php \Drupal\Core\Database\Driver\sqlite\Install\Tasks::getFormOptions()
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php \Drupal\Core\Database\Driver\mysql\Install\Tasks::getFormOptions()
- 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php \Drupal\Core\Database\Driver\pgsql\Install\Tasks::getFormOptions()
Same name in other branches
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Install/Tasks.php \Drupal\sqlite\Driver\Database\sqlite\Install\Tasks::getFormOptions()
- 9 core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php \Drupal\mysql\Driver\Database\mysql\Install\Tasks::getFormOptions()
- 9 core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php \Drupal\pgsql\Driver\Database\pgsql\Install\Tasks::getFormOptions()
- 9 core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::getFormOptions()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Install/Tasks.php \Drupal\sqlite\Driver\Database\sqlite\Install\Tasks::getFormOptions()
- 10 core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php \Drupal\mysql\Driver\Database\mysql\Install\Tasks::getFormOptions()
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php \Drupal\pgsql\Driver\Database\pgsql\Install\Tasks::getFormOptions()
- 10 core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::getFormOptions()
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Install/Tasks.php \Drupal\sqlite\Driver\Database\sqlite\Install\Tasks::getFormOptions()
- 11.x core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php \Drupal\mysql\Driver\Database\mysql\Install\Tasks::getFormOptions()
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php \Drupal\pgsql\Driver\Database\pgsql\Install\Tasks::getFormOptions()
- 11.x core/lib/Drupal/Core/Database/Install/Tasks.php \Drupal\Core\Database\Install\Tasks::getFormOptions()
Return driver specific configuration options.
Parameters
$database: An array of driver specific configuration options.
Return value
The options form array.
3 calls to Tasks::getFormOptions()
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ sqlite/ Install/ Tasks.php - Return driver specific configuration options.
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Install/ Tasks.php - Return driver specific configuration options.
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ pgsql/ Install/ Tasks.php - Return driver specific configuration options.
3 methods override Tasks::getFormOptions()
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ sqlite/ Install/ Tasks.php - Return driver specific configuration options.
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Install/ Tasks.php - Return driver specific configuration options.
- Tasks::getFormOptions in core/
lib/ Drupal/ Core/ Database/ Driver/ pgsql/ Install/ Tasks.php - Return driver specific configuration options.
File
-
core/
lib/ Drupal/ Core/ Database/ Install/ Tasks.php, line 217
Class
- Tasks
- Database installer structure.
Namespace
Drupal\Core\Database\InstallCode
public function getFormOptions(array $database) {
// Use reflection to determine the driver name.
// @todo https:///www.drupal.org/node/3123240 Provide a better way to get
// the driver name.
$reflection = new \ReflectionClass($this);
$dir_parts = explode(DIRECTORY_SEPARATOR, dirname(dirname($reflection->getFileName())));
$driver = array_pop($dir_parts);
$form['database'] = [
'#type' => 'textfield',
'#title' => t('Database name'),
'#default_value' => empty($database['database']) ? '' : $database['database'],
'#size' => 45,
'#required' => TRUE,
'#states' => [
'required' => [
':input[name=driver]' => [
'value' => $driver,
],
],
],
];
$form['username'] = [
'#type' => 'textfield',
'#title' => t('Database username'),
'#default_value' => empty($database['username']) ? '' : $database['username'],
'#size' => 45,
'#required' => TRUE,
'#states' => [
'required' => [
':input[name=driver]' => [
'value' => $driver,
],
],
],
];
$form['password'] = [
'#type' => 'password',
'#title' => t('Database password'),
'#default_value' => empty($database['password']) ? '' : $database['password'],
'#required' => FALSE,
'#size' => 45,
];
$form['advanced_options'] = [
'#type' => 'details',
'#title' => t('Advanced options'),
'#weight' => 10,
];
global $install_state;
// @todo https://www.drupal.org/project/drupal/issues/3110839 remove PHP 7.4
// work around and add a better message for the migrate UI.
$profile = $install_state['parameters']['profile'] ?? NULL;
$db_prefix = $profile == 'standard' ? 'drupal_' : $profile . '_';
$form['advanced_options']['prefix'] = [
'#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.', [
'%prefix' => $db_prefix,
]),
'#weight' => 10,
];
$form['advanced_options']['host'] = [
'#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'] = [
'#type' => 'number',
'#title' => t('Port number'),
'#default_value' => empty($database['port']) ? '' : $database['port'],
'#min' => 0,
'#max' => 65535,
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.