function FileTransfer::getSettingsForm

Same name in other branches
  1. 7.x includes/filetransfer/filetransfer.inc \FileTransfer::getSettingsForm()
  2. 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::getSettingsForm()
  3. 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::getSettingsForm()
  4. 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::getSettingsForm()

Returns a form to collect connection settings credentials.

Implementing classes can either extend this form with fields collecting the specific information they need, or override it entirely.

Return value

array An array that contains a Form API definition.

2 calls to FileTransfer::getSettingsForm()
FTP::getSettingsForm in core/lib/Drupal/Core/FileTransfer/FTP.php
Returns a form to collect connection settings credentials.
SSH::getSettingsForm in core/lib/Drupal/Core/FileTransfer/SSH.php
Returns a form to collect connection settings credentials.
3 methods override FileTransfer::getSettingsForm()
FTP::getSettingsForm in core/lib/Drupal/Core/FileTransfer/FTP.php
Returns a form to collect connection settings credentials.
SSH::getSettingsForm in core/lib/Drupal/Core/FileTransfer/SSH.php
Returns a form to collect connection settings credentials.
TestFileTransferWithSettingsForm::getSettingsForm in core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php
Returns a settings form with a text field to input a username.

File

core/lib/Drupal/Core/FileTransfer/FileTransfer.php, line 393

Class

FileTransfer
Defines the base FileTransfer class.

Namespace

Drupal\Core\FileTransfer

Code

public function getSettingsForm() {
    $form['username'] = [
        '#type' => 'textfield',
        '#title' => t('Username'),
    ];
    $form['password'] = [
        '#type' => 'password',
        '#title' => t('Password'),
        '#description' => t('Your password is not saved in the database and is only used to establish a connection.'),
    ];
    $form['advanced'] = [
        '#type' => 'details',
        '#title' => t('Advanced settings'),
    ];
    $form['advanced']['hostname'] = [
        '#type' => 'textfield',
        '#title' => t('Host'),
        '#default_value' => 'localhost',
        '#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'),
    ];
    $form['advanced']['port'] = [
        '#type' => 'textfield',
        '#title' => t('Port'),
        '#default_value' => NULL,
    ];
    return $form;
}

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