You are here

public function PardotFormMappingForm::submitForm in Pardot Integration 2.x

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/PardotFormMappingForm.php, line 82

Class

PardotFormMappingForm
Class PardotFormMappingForm.

Namespace

Drupal\pardot\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Display result.
  $values = $form_state
    ->getValues();
  $pardot_form_mapping = $values['pardot_form_mapping'] ?? FALSE;
  $entity = $form_state
    ->get('entity');
  $form_map_plugin_instance_id = $form_state
    ->get('form_map_plugin_instance_id');
  if ($pardot_form_mapping && $form_map_plugin_instance_id && $entity) {
    $plugin = $this->pluginManagerFormMapHandlerPlugin;
    $plugin = $plugin
      ->createInstance($form_map_plugin_instance_id);
    $plugin = PluginSubFormHelpers::pluginSubmit($plugin, $form, $form_state, [
      'pardot_form_mapping',
    ]);
    $entity
      ->setThirdPartySetting('pardot', 'pardot_form_mapping_plugin', $plugin
      ->getConfiguration());
    $entity
      ->save();
  }
}