As you've already discovered, ConfirmFormBase
just provides some buttons, handling for messages, and submit/cancel logic. On its own, it's not designed to be used as the sort of multistep form you're looking for.
Getting that functionality is pretty easy though; you could use the logic in Drupal\config\Form\ConfigSingleImportForm
as a rough example. Basically you just handle the multistep part of it yourself. For example:
protected $step = 1;
public function buildForm(array $form, FormStateInterface $form_state) {
// When this is the confirmation step fall through to the confirmation form.
if ($this->step === 2) {
return parent::buildForm($form, $form_state);
}
// Build and return your upload form as normal, but don't call the parent method.
}
public function validateForm(array &$form, FormStateInterface $form_state) {
// The confirmation step needs no additional validation.
if ($this->step === 2) {
return;
}
// Perform any additional validation
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($this->step === 1) {
$form_state->setRebuild();
$this->step = 2;
return;
}
// Extract rows from CSV and set batch to import here
}