function RestExampleClientSettings::buildForm

Same name in other branches
  1. 4.0.x modules/rest_example/src/Form/RestExampleClientSettings.php \Drupal\rest_example\Form\RestExampleClientSettings::buildForm()

Overrides ConfigFormBase::buildForm

File

modules/rest_example/src/Form/RestExampleClientSettings.php, line 27

Class

RestExampleClientSettings
Setup form for a Drupal REST client.

Namespace

Drupal\rest_example\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['intro'] = [
        '#markup' => t('Set here the remote server options.'),
    ];
    $form['server_url'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Remote server URL'),
        '#description' => $this->t('Format like this: http://www.example.com or http://www.example.com/test-site (no trailing slash)'),
        '#default_value' => $this->config('rest_example.settings')
            ->get('server_url'),
        '#required' => TRUE,
    ];
    $form['server_username'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Remote server username'),
        '#default_value' => $this->config('rest_example.settings')
            ->get('server_username'),
        '#description' => $this->t('A user on the remote system that has the proper rights to use the REST service'),
        '#required' => TRUE,
    ];
    $form['server_password'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Remote server password'),
        '#default_value' => $this->config('rest_example.settings')
            ->get('server_password'),
        '#description' => $this->t('Remote users password'),
        '#required' => TRUE,
    ];
    return parent::buildForm($form, $form_state);
}