You are here

public function BackupDatabaseForm::buildForm in Backup Database 8

@todo, displays last backup timestamp

Overrides FormInterface::buildForm

File

src/Form/BackupDatabaseForm.php, line 34
Contains \Drupal\backup_db\Form\BackupDatabaseForm.

Class

BackupDatabaseForm
BackupDatabaseForm class.

Namespace

Drupal\backup_db\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('backup_db.settings');
  $site_name = \Drupal::config('system.site')
    ->get('name');

  // General.
  $form['filename'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Filename'),
    '#description' => $this
      ->t('The prefix name of the sql dump file.'),
    '#default_value' => $config
      ->get('filename') ? $config
      ->get('filename') : $site_name,
  );
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => $this
      ->t('Export type'),
    '#options' => array(
      'local' => $this
        ->t('Local'),
      'download' => $this
        ->t('Download'),
    ),
    '#description' => $this
      ->t('Export backup to local server or download.'),
    '#default_value' => 'download',
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Export'),
    '#button_type' => 'primary',
  );
  return $form;
}