You are here

function _set_pardot_form_submit in Pardot Integration 2.x

Set Pardot form submit.

Parameters

object $entity: The entity (form) you want to attach the pardot form submit functionality.

\Drupal\Core\Form\FormStateInterface $form_state: Form state interface.

See also

pardot_form_contact_message_form_alter()

2 calls to _set_pardot_form_submit()
pardot_form_contact_message_form_alter in ./pardot.module
Implements hook_form_FORM_ID_alter().
pardot_webform_submission_form_alter in ./pardot.module

File

./pardot.module, line 169
Contains pardot.module.

Code

function _set_pardot_form_submit(object $entity, &$form, FormStateInterface $form_state) {
  $pardot_form_map_plugin = $entity
    ->getThirdPartySetting('pardot', 'pardot_form_mapping_plugin', FALSE);
  if ($pardot_form_map_plugin) {
    $pardot_form_map = new FormMap($pardot_form_map_plugin['settings']);
    if ($pardot_form_map) {
      $storage = $form_state
        ->getStorage();
      $storage['pardot_form_map'] = $pardot_form_map;

      // Add submit handler if we have an enabled contact form mapping.
      $form_state
        ->setStorage($storage);
      $form['actions']['submit']['#submit'][] = '_pardot_form_submit';
    }
  }
}