diff --git a/core/modules/migrate_drupal_ui/src/Form/CredentialForm.php b/core/modules/migrate_drupal_ui/src/Form/CredentialForm.php index 869dbfe2cb..718dadde29 100644 --- a/core/modules/migrate_drupal_ui/src/Form/CredentialForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/CredentialForm.php @@ -25,7 +25,7 @@ class CredentialForm extends MigrateUpgradeFormBase { protected $renderer; /** - * The HTTP client to fetch the feed data with. + * The HTTP client to fetch the files with. * * @var \GuzzleHttp\ClientInterface */ @@ -243,14 +243,18 @@ public function validateForm(array &$form, FormStateInterface $form_state) { // Setup migrations and save form data to private store. $this->setupMigrations($database, $form_state); } - } catch (\Exception $e) { - $this->errors[$driver] = $e->getMessage(); + } + catch (\Exception $e) { + $this->errors[$database['driver'] . '][database'] = $e->getMessage(); } } // Display all errors as a list of items. if ($this->errors) { - $this->buildErrorList($this->errors, $form_state); + $form_state->setError($form, $this->t('

Resolve all issues below to continue the upgrade.

')); + foreach ($this->errors as $name => $message) { + $form_state->setErrorByName($name, $message); + } } } @@ -277,38 +281,6 @@ public function validatePaths($element, FormStateInterface $form_state) { } /** - * Builds list of errors for display. - * - * @param array $errors - * Associative array of errors keyed by element name. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The form state. - */ - protected function buildErrorList(array $errors, FormStateInterface $form_state) { - $items = []; - // To display all the errors found, set the error on the form field name for - // error and add each message to an array for later display. - foreach ($errors as $name => $message) { - $form_state->setErrorByName($name); - $items[] = $message; - } - - $list = [ - '#title' => $this->t('Resolve all issues below to continue the upgrade.'), - '#theme' => 'item_list', - '#items' => $items, - ]; - $name = current(array_keys($errors)); - // Use the field name of the first error as the name for setErrorByName. Add - // '][0' so that all children of the field are included. Only the database - // connection has children and since the errors are generic, except for - // the prefix which is tested in validateDatabaseSettings, we do not have - // any specific key to attach them to; therefore, we just put them in the - // error array with standard numeric keys. - $form_state->setErrorByName($name . '][0', $this->renderer->renderPlain($list)); - } - - /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) {