public function HubspotWebformHandler::submitConfigurationForm in HubSpot 3.x
Same name and namespace in other branches
- 8 src/Plugin/WebformHandler/HubspotWebformHandler.php \Drupal\hubspot\Plugin\WebformHandler\HubspotWebformHandler::submitConfigurationForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides WebformHandlerBase::submitConfigurationForm
File
- src/
Plugin/ WebformHandler/ HubspotWebformHandler.php, line 604
Class
- HubspotWebformHandler
- Webform submission remote post handler.
Namespace
Drupal\hubspot\Plugin\WebformHandlerCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
if (!$this->hubspot
->isConfigured()) {
return;
}
$form_values = $form_state
->getValues();
$hubspot_id = $form_values['mapping']['hubspot_form'];
$fields = $form_values['mapping']['field_group']['fields'];
$settings = [];
// Add new field mapping.
if ($hubspot_id != '--donotmap--') {
$settings['form_guid'] = $hubspot_id;
$settings['field_mapping'] = array_filter($fields, function ($hubspot_field) {
return $hubspot_field !== '--donotmap--';
});
$this
->messenger()
->addMessage($this
->t('Saved new field mapping.'));
}
$settings['legal_consent'] = $form_values['legal_consent'];
if ($settings['legal_consent']['include'] != 'conditionally') {
unset($settings['legal_consent']['source']);
}
$settings['subscriptions'] = $form_values['subscriptions']['mapping'];
$this
->setSettings($settings);
}