You are here

public function SettingsProfileForm::form in Backup and Migrate 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Form/SettingsProfileForm.php \Drupal\backup_migrate\Form\SettingsProfileForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/SettingsProfileForm.php, line 19

Class

SettingsProfileForm
@package Drupal\backup_migrate\Form

Namespace

Drupal\backup_migrate\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $backup_migrate_settings = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $backup_migrate_settings
      ->label(),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $backup_migrate_settings
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\backup_migrate\\Entity\\SettingsProfile::load',
    ],
    '#disabled' => !$backup_migrate_settings
      ->isNew(),
  ];

  // Make sure the config is a valid empty array.
  // @todo Is this a bug in the API?
  $config = $backup_migrate_settings
    ->get('config');
  if (empty($config)) {
    $config = [];
  }
  $bam = backup_migrate_get_service_object($config);
  $form['config'] = DrupalConfigHelper::buildAllPluginsForm($bam
    ->plugins(), 'backup', [
    'config',
  ]);
  return $form;
}