You are here

public function SyncConfigureForm::buildForm in Configuration installer 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/SyncConfigureForm.php, line 35

Class

SyncConfigureForm
Installation step to configure sync directory or upload a tarball.

Namespace

Drupal\config_installer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this
    ->t('Configure configuration import location');
  $form['sync_directory'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Synchronisation directory'),
    '#default_value' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
    '#maxlength' => 255,
    '#description' => $this
      ->t('Path to the config directory you wish to import, can be relative to document root or an absolute path.'),
    '#required' => TRUE,
    // This value can only be changed if settngs.php is writable.
    '#disabled' => !is_writable(\Drupal::service('site.path') . '/settings.php'),
  ];
  $form['import_tarball'] = [
    '#type' => 'file',
    '#title' => $this
      ->t('Select your configuration export file'),
    '#description' => $this
      ->t('If the sync directory is empty you can upload a configuration export file.'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save and continue'),
    '#weight' => 15,
    '#button_type' => 'primary',
  ];
  return $form;
}