function pardot_webform_submission_form_alter in Pardot Integration 2.x
File
- ./
pardot.module, line 116 - Contains pardot.module.
Code
function pardot_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
// Get conditional state variable.
// @see \Drupal\pardot\EventSubscriber\PardotEventSubscriber
$include_tracking = (bool) \Drupal::state()
->get('pardot.include_tracking') ?: 0;
$config = \Drupal::config('pardot.settings');
if (NULL !== $config
->get('account_id') && $include_tracking) {
$bundle = FALSE;
$form_object = $form_state
->getFormObject();
if ($form_object instanceof WebformSubmissionForm) {
$bundle = $form_object
->getEntity()
->bundle();
/** @var \Drupal\webform\Element\Webform $entity */
$entity = \Drupal::entityTypeManager()
->getStorage('webform')
->load($bundle);
_set_pardot_form_submit($entity, $form, $form_state);
}
}
}