public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->cleanValues(); /** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */ $fillpdf_form = $this->getEntity(); $mappings = $form_state->getValue('mappings'); /** @var \Drupal\fillpdf\FillPdfFormInterface $imported_form */ $imported_form = $mappings['form']; /** @var array $imported_fields */ $imported_fields = $mappings['fields']; $unmatched_pdf_keys = $this->serializer->importForm($fillpdf_form, $imported_form, $imported_fields); foreach ($unmatched_pdf_keys as $unmatched_pdf_key) { drupal_set_message($this->t('Your code contained field mappings for the PDF field key <em>@pdf_key</em>, but it does not exist on this form. Therefore, it was ignored.', ['@pdf_key' => $unmatched_pdf_key]), 'warning'); } drupal_set_message($this->t('Successfully imported FillPDF form configuration and matching PDF field keys. If any field mappings failed to import, they are listed above.')); $form_state->setRedirect('entity.fillpdf_form.edit_form', ['fillpdf_form' => $fillpdf_form->id()]); }