Set default port for Postgres connections if it's the first available driver
refs #9683
This commit is contained in:
parent
f46504554e
commit
06c6b09863
|
@ -30,20 +30,26 @@ class DbResourceForm extends Form
|
||||||
if (Platform::hasMysqlSupport()) {
|
if (Platform::hasMysqlSupport()) {
|
||||||
$dbChoices['mysql'] = 'MySQL';
|
$dbChoices['mysql'] = 'MySQL';
|
||||||
}
|
}
|
||||||
|
if (Platform::hasPostgresqlSupport()) {
|
||||||
|
$dbChoices['pgsql'] = 'PostgreSQL';
|
||||||
|
}
|
||||||
if (Platform::hasMssqlSupport()) {
|
if (Platform::hasMssqlSupport()) {
|
||||||
$dbChoices['mssql'] = 'MSSQL';
|
$dbChoices['mssql'] = 'MSSQL';
|
||||||
}
|
}
|
||||||
if (Platform::hasOciSupport()) {
|
|
||||||
$dbChoices['oci'] = 'Oracle (OCI8)';
|
|
||||||
}
|
|
||||||
if (Platform::hasOracleSupport()) {
|
if (Platform::hasOracleSupport()) {
|
||||||
$dbChoices['oracle'] = 'Oracle';
|
$dbChoices['oracle'] = 'Oracle';
|
||||||
}
|
}
|
||||||
if (Platform::hasPostgresqlSupport()) {
|
if (Platform::hasOciSupport()) {
|
||||||
$dbChoices['pgsql'] = 'PostgreSQL';
|
$dbChoices['oci'] = 'Oracle (OCI8)';
|
||||||
|
}
|
||||||
|
$offerPostgres = false;
|
||||||
|
if (isset($formData['db'])) {
|
||||||
|
if ($formData['db'] === 'pgsql') {
|
||||||
|
$offerPostgres = true;
|
||||||
|
}
|
||||||
|
} elseif (key($dbChoices) === 'pgsql') {
|
||||||
|
$offerPostgres = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'name',
|
'name',
|
||||||
|
@ -81,8 +87,8 @@ class DbResourceForm extends Form
|
||||||
'description' => $this->translate('The port to use'),
|
'description' => $this->translate('The port to use'),
|
||||||
'label' => $this->translate('Port'),
|
'label' => $this->translate('Port'),
|
||||||
'preserveDefault' => true,
|
'preserveDefault' => true,
|
||||||
'required' => isset($formData['db']) && $formData['db'] === 'pgsql',
|
'required' => $offerPostgres,
|
||||||
'value' => isset($formData['db']) && $formData['db'] === 'pgsql' ? 5432 : null
|
'value' => $offerPostgres ? 5432 : null
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
|
|
Loading…
Reference in New Issue