/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
 $form['actions'] = [
   '#type' => 'actions',
 ];
 if ($markup = $form_state->get('stats_markup')) {
   $form['markup_fielset'] = [
     '#type' => 'fieldset',
     '#title' => $this->t('Statistics'),
   ];
   $form['markup_fielset']['markup'] = [
     '#type' => 'item',
     '#markup' => $markup,
   ];
 }
 $form['actions']['submit'] = [
   '#type' => 'submit',
   '#value' => $this->t('Show statistics'),
 ];
 return $form;
}
/**
 * {@inheritdoc}
 */
public function submitForm(array &$form, FormStateInterface $form_state) {
 $markup = 'Set custom markup';
 $form_state->set('stats_markup', $markup);
 $form_state->setRebuild();
}